Skip to content

Conversation

@sarthakNITT
Copy link
Contributor

Description

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

@changeset-bot
Copy link

changeset-bot bot commented Aug 2, 2025

🦋 Changeset detected

Latest 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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2025

Changeset has been generated for this PR as part of auto-changeset workflow.

Please review the changeset before merging the PR.
---
'@asyncapi/cli': minor
---

feat: validate Avro schemas in AsyncAPI files using CLI

- cafcc85: feat: added avro validation

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 skip-changeset to the PR or remove the changeset and change PR title to something other than fix: or feat:.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 2, 2025

@sarthakNITT
Copy link
Contributor Author

Hi @Souvikns,

Can you please review the pr.

Comment on lines 67 to 69
if (schemaFormat?.startsWith('application/vnd.apache.avro')) {
try {
avro.Type.forSchema(schema);

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?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2025

@sarthakNITT
Copy link
Contributor Author

@Lazzaretti That file is removed in the latest commit. Made changes and have raised a pr, please review it.

@Shurtu-gal
Copy link
Collaborator

@sarthakNITT could you please provide a update on this?

@Shurtu-gal
Copy link
Collaborator

/u

@sonarqubecloud
Copy link

@sarthakNITT
Copy link
Contributor Author

@Shurtu-gal Made changes, Please review it.

@Shurtu-gal
Copy link
Collaborator

Personally I think this issue should be transferred to avro-schema-parser as we are already registering that in validation-service in:

this.parser.registerSchemaParser(AvroSchemaParser());

@sarthakNITT
Copy link
Contributor Author

@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?
If so, I'll close this PR, revert the changes, and open a new PR in the avro-schema-parser repo.

@Shurtu-gal
Copy link
Collaborator

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.

@sarthakNITT
Copy link
Contributor Author

okay, can you please tell me whose the maintainer of that repo?

@Shurtu-gal
Copy link
Collaborator

Please check CODEOWNERS file there.

const schemaFormat = message.schemaFormat();
if (!schemaFormat) {continue;}

const isAvro = (/application\/vnd\.apache\.avro\+(json|yaml)/i).test(schemaFormat);

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

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?

Comment on lines +317 to +318
start: { line: 0, character: 0 },
end: { line: 0, character: 0 },

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?

Comment on lines +334 to +335
start: { line: 0, character: 0 },
end: { line: 0, character: 0 },

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?

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

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[FEATURE] Avro Validation

4 participants