-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
javascript map() function doesn't work on SecurityRequirements object. #874
Comments
@KhudaDad414 something is off here.
is no longer an array but a specific entry in the How this works fine:
Does not really make sense to me 😅 |
@jonaslagoni that's what I am saying. 😆
asyncapi: 3.0.0
info:
title: Slack Websocket and OpenAI API
version: 1.0.0
servers:
OpenAI_HTTPS:
host: api.openai.com
protocol: https
security:
- $ref: '#/components/securitySchemes/my'
components:
securitySchemes:
my:
type: http
scheme: bearer
import Parser from "@asyncapi/parser"
const file = await Bun.file("asyncapi.yaml").text()
const parser = new Parser()
const { document, diagnostics } = await parser.parse(file)
if (!document) {
console.log("error parsing the document", diagnostics)
}
const securityRequirements = document?.allServers()[0].security()[0]
if (!securityRequirements) {
process.exit(0)
}
// Works fine
for (const security of securityRequirements) {
console.log("In a for loop: ", security.jsonPath())
}
//Works fine
securityRequirements?.forEach((securityRequirement) => {
console.log("in a forEach: ", securityRequirement.jsonPath())
})
//Throws error
try {
securityRequirements?.map((securityRequirement) => {
console.log(securityRequirement.jsonPath())
return securityRequirement.jsonPath()
})
} catch (e) {
console.log("I throw errors.")
}
yes, it behaves the same way in node as well. |
@smoya any idea why this is happening? |
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
Describe the bug
SecurityRequirements object acts as a javascript array in some ways but not in all of the cases.
consider this example:
the last case will Throw:
The text was updated successfully, but these errors were encountered: