Skip to content

feat: validate unparsed AsyncAPI document - #720

Merged
asyncapi-bot merged 2 commits into
asyncapi:next-majorfrom
magicmatatjahu:next/validate-unparsed-spec
Feb 9, 2023
Merged

asyncapi-bot merged 2 commits into
asyncapi:next-majorfrom
magicmatatjahu:next/validate-unparsed-spec

Conversation

@magicmatatjahu

Copy link
Copy Markdown
Member

Description

Validate unparsed AsyncAPI document (before $refs resolving).

@magicmatatjahu

Copy link
Copy Markdown
Member Author

@jonaslagoni Could you check?

@jonaslagoni jonaslagoni left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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

magicmatatjahu commented Feb 7, 2023 •

Copy link
Copy Markdown
Member Author

@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

jonaslagoni commented Feb 8, 2023 •

Copy link
Copy Markdown
Member

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

magicmatatjahu commented Feb 8, 2023 •

Copy link
Copy Markdown
Member Author

@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.

@sonarqubecloud

sonarqubecloud Bot commented Feb 9, 2023

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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