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

Validate default schema format examples #781

Closed
chrispatmore opened this issue Jun 6, 2023 · 3 comments
Closed

Validate default schema format examples #781

chrispatmore opened this issue Jun 6, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@chrispatmore
Copy link
Contributor

Reason/Context

As an extension to #772 instead of not validating non default schema format examples. the parser should validate that the example is valid w.r.t to the schema regardless of format. This gives increased confidence that the complete document is valid.

Description

To do this a new rule will have to be introduced which like the src/schema-parser/spectral-rule-v2.ts rule will take in the parser instance. This will be used to parse the schema in the provided format to the default format, which can then be used to validate the examples against the schema.

The old rule can renamed to something like asyncapi2-message-examples-default and the new rule would be asyncapi2-message-examples like the asyncapi2-schemas rule and equivalent asyncapi2-schemas-default rule there at the moment.

This would be a breaking change for anyone that had an invalid example for a schema provided with the non default schema format. However it was only possible to do that after #772 was completed, so it is unlikely there will be any people in this situtation at the moment.

I have code ready for this that can be reviewed alongside the issue. It didn't take that long so I won't be at all bothered if the decision is not do this feature

@chrispatmore chrispatmore added the enhancement New feature or request label Jun 6, 2023
@chrispatmore
Copy link
Contributor Author

@jonaslagoni I have raised this extension feature request as discussed
I can create a PR for this feature now or wait for discussion on whether to do it

@jonaslagoni
Copy link
Member

Feel free to create the PR @chrispatmore, if you can just add the new spectral rules for non-default schema formats, we can always create an issue for when we want to include them in a major version.

Unless you feel like its required 🤔?

@chrispatmore
Copy link
Contributor Author

No I don't think it's required, will raise it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants