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

Audit: add JSON Schema for topics and enable it for yml files #57

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

lieser
Copy link
Collaborator

@lieser lieser commented Jun 20, 2023

JSON Schema can be used to not just validate JSON, but als YAML files. The YAML extension of VS Code supports this.
Use this to to add auto completion and validation of the topic files in local development.

  • Adds the YAML extension to the list of recommended extensions.
  • Add a JSON Schema for topics.
  • Enable the JSON Schema for the YAML files of the topics in the audit report.

@lieser lieser added enhancement New feature or request auditreport labels Jun 20, 2023
@lieser lieser self-assigned this Jun 20, 2023
Copy link
Collaborator

@reneme reneme left a comment

Choose a reason for hiding this comment

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

That's nice! Didn't occur to me to use JSON Schema for that. 😃
A few days ago, I added some consistency checks to the python generator that is supposed to catch unwanted (aka: misspelled) fields. Is there a way to verify the .yml files against this schema in CI?

Comment on lines +80 to +82
"required": [
"classification"
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity: What's the advantage of requiring the classification here instead of inside the oneOf variant declarations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The only advantage is not having to write it two times.

Best would be if we could define classification, auditer and comment here completly (not just the required). But that requires the unevaluatedProperties feature, which does not work for the extension redhat-developer/vscode-yaml#704.

@lieser
Copy link
Collaborator Author

lieser commented Jun 21, 2023

Is there a way to verify the .yml files against this schema in CI?

According to https://stackoverflow.com/questions/3262569/validating-a-yaml-document-in-python it should be possible to verify it in Python with PyYAML and jsonschema.

But would leave that as a follow up.

@lieser lieser merged commit 31b96c2 into main Jun 21, 2023
@lieser lieser deleted the audit/topic_schema branch June 21, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auditreport enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants