Skip to content
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

feat: validate unparsed AsyncAPI document #720

Merged

Conversation

magicmatatjahu
Copy link
Member

Description

Validate unparsed AsyncAPI document (before $refs resolving).

@magicmatatjahu
Copy link
Member Author

@jonaslagoni Could you check?

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I dont understand why we don't change the parsing logic to validate before resolving references, and then again after? This fix looks like an incorrect approach to take 🤔 Or is there some underlying reason?

Related to #405

},
errors: [
{
message: 'Referencing in this place is not allowed',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Is it not caught by the spec-schema?

},
errors: [
{
message: 'Referencing in this place is not allowed',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? Is it not caught by the spec-schema?

@magicmatatjahu
Copy link
Member Author

magicmatatjahu commented Feb 7, 2023

@jonaslagoni

I guess I dont understand why we don't change the parsing logic to validate before resolving references, and then again after? This fix looks like an incorrect approach to take 🤔 Or is there some underlying reason?

Spectral resolver (and other json-schema resolvers) doesn't validate the json-schema but only resolve it. Also AJV try to validate the spec based on json-schema and that's the problem. After referencing we don't know if $ref in given place can be located and/or given ref has valid object (for given location, e.g. message etc.). So we exactly validate two things: unresolved AsyncAPI document with refs and with resolved refs (even that deep). I don't know how to make it in different way. That PR is related to the #405

@jonaslagoni
Copy link
Member

jonaslagoni commented Feb 8, 2023

Ahh shit, validation happens through spectral now, yea then you can't do a simple double validation once before refs are resolved and once after...

Right?

@magicmatatjahu
Copy link
Member Author

magicmatatjahu commented Feb 8, 2023

@jonaslagoni

Ahh shit, validation happens through spectral now, yea then you can't do a simple double validation once before refs are resolved and once after...

this is what I do 😄 underneath is AJV and JSON Schema validation.

@sonarcloud
Copy link

sonarcloud bot commented Feb 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@magicmatatjahu
Copy link
Member Author

/rtm

@asyncapi-bot asyncapi-bot merged commit 9e6da02 into asyncapi:next-major Feb 9, 2023
@magicmatatjahu magicmatatjahu deleted the next/validate-unparsed-spec branch February 9, 2023 12:41
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.0-next-major.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants