-
Notifications
You must be signed in to change notification settings - Fork 21
feat(apidom-reference): resolve references async v3 #5051
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
base: main
Are you sure you want to change the base?
Conversation
| import * as openapi3_1AdapterYaml from '@swagger-api/apidom-parser-adapter-openapi-yaml-3-1'; | ||
| import * as asyncapi2AdapterJson from '@swagger-api/apidom-parser-adapter-asyncapi-json-2'; | ||
| import * as asyncapi2AdapterYaml from '@swagger-api/apidom-parser-adapter-asyncapi-yaml-2'; | ||
| import * as asyncapi3AdapterYaml from '@swagger-api/apidom-parser-adapter-asyncapi-yaml-3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add JSON parser adapter as well?
| if (contentLanguage.namespace === 'asyncapi' && contentLanguage.format === 'JSON') { | ||
| if ( | ||
| contentLanguage.namespace === 'asyncapi' && | ||
| (contentLanguage.version?.startsWith('2.') || !contentLanguage.version) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the first condition not be enough?
| (contentLanguage.version?.startsWith('2.') || !contentLanguage.version) && | |
| contentLanguage.version?.startsWith('2.') && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately there were tests failing without additional condition
| ({ hasBasicElementProps, isElementType, primitiveEq, hasClass }) => { | ||
| return (element: unknown): element is AsyncApi2Element => | ||
| element instanceof AsyncApi2Element || | ||
| (element instanceof AsyncApi2Element && element.constructor === AsyncApi2Element) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that other predicates for the root element do not have this - is there some issue when it's not here?
| (element instanceof AsyncApi2Element && element.constructor === AsyncApi2Element) || | |
| (element instanceof AsyncApi2Element || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the method returns true for the AsyncApi3 as well which is unwanted.
| return !parent ? mergedElement : false; | ||
| } | ||
|
|
||
| public async ChannelItemElement( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will never visit here because ChannelItemElement does not exist in AsyncAPI 3.x. We also don't need additional handling for ChannelElement - it was needed for ChannelItemElement because it had the $ref field, while it does not exist for ChannelElement. As such, I think this can be removed.
| }); | ||
| refSet.add(immutableReference); | ||
| } | ||
| // eslint-disable-next-line no-debugger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // eslint-disable-next-line no-debugger |
Resolve references for async v3