-
-
Notifications
You must be signed in to change notification settings - Fork 288
feat: validate Avro schemas in AsyncAPI files using CLI #1833
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: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 2252fad The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Changeset has been generated for this PR as part of auto-changeset workflow.Please review the changeset before merging the PR.If you are a maintainer or the author of the PR, you can change the changeset by clicking here Tip If you don't want auto-changeset to run on this PR, you can add the label |
|
|
Hi @Souvikns, Can you please review the pr. |
src/commands/validate.ts
Outdated
| if (schemaFormat?.startsWith('application/vnd.apache.avro')) { | ||
| try { | ||
| avro.Type.forSchema(schema); |
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.
The mime type can also contain the Avro version. Is this not also needed for the validation of Avro?
92ffdfc to
cafcc85
Compare
|
|
@Lazzaretti That file is removed in the latest commit. Made changes and have raised a pr, please review it. |
|
@sarthakNITT could you please provide a update on this? |
|
/u |
|
|
@Shurtu-gal Made changes, Please review it. |
|
Personally I think this issue should be transferred to avro-schema-parser as we are already registering that in validation-service in:
|
|
@Shurtu-gal Just to confirm I understand correctly: you'd like me to move the Avro schema validation logic (using avsc) directly into the asyncapi/avro-schema-parser package instead of handling it here in the CLI's validation service? |
|
Exactly but instead of creating a PR there it would be better to first shift the issue ask maintainers there what should be done then start working. |
|
okay, can you please tell me whose the maintainer of that repo? |
|
Please check CODEOWNERS file there. |
| const schemaFormat = message.schemaFormat(); | ||
| if (!schemaFormat) {continue;} | ||
|
|
||
| const isAvro = (/application\/vnd\.apache\.avro\+(json|yaml)/i).test(schemaFormat); |
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.
This string matches only if a +json or +yaml is present.
As I understand the spec, a valid Avro schema format can also be application/vnd.apache.avro;version=1.9.0
see: https://www.asyncapi.com/docs/reference/specification/v3.0.0#multiFormatSchemaFormatTable
| } | ||
| } | ||
| } catch (e) { | ||
| // console.error(e); // Context: silent failure for extra validation |
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.
Would this not also hint at a problem that should create a diagnostic message?
| start: { line: 0, character: 0 }, | ||
| end: { line: 0, character: 0 }, |
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 can go to the range where the schemaFormat is defined here?
| start: { line: 0, character: 0 }, | ||
| end: { line: 0, character: 0 }, |
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 can go to the range where the schema is defined here?



Description
fixed #1813
installed "avsc": "^5.7.9",
code changes in ./src/commands/validate.ts file