-
Notifications
You must be signed in to change notification settings - Fork 32
Yaml source of truth for JSON schema files #411
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
Yaml source of truth for JSON schema files #411
Conversation
c33083a to
0394f95
Compare
0394f95 to
8e73ca3
Compare
| <summary>JSON Schema</summary> | ||
|
|
||
| [JSON Schema Source File](./schema/meter_provider.json) | ||
| [JSON Schema Source File](./schema/meter_provider.yaml) |
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.
Fun fact - you can tell its a strict refactoring of build tooling because schema-docs.md basically doesn't change besides this trivial bit pointing to the new source location.
|
Ok in principle. The concern is to avoid merge collisions if another PR changes the schema in the mean time, but the generated schema-docs.md file serves as a verification for that, so it looks safe. |
| Object.keys(fileContentByFile).forEach(file => { | ||
| const jsonFile = file.replace('.yaml', '.json'); | ||
| Object.entries(fileContentByFile).forEach(([otherFile, otherContent]) => { | ||
| fileContentByFile[otherFile] = otherContent.replaceAll(`$ref: ${file}`, `$ref: ${jsonFile}`); |
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 realized that maintaining "pre compiled" source for JSON schema definitions complicates the picture for $refs - do refs point at the .yaml or .json (which doesn't exist until you run make compile-schema?
Solved this by adjusting all $refs to point .yaml for a more intuitive editing experience, and replacing .yaml to .json as a part of the process of writing out the JSON schema files.
At the same time, I realized this is a good place to force standardization for the $id and $schema properties each file needs to contain. (see below)
But this got me thinking and worrying (once again) about $id and resolving $refs for tooling. Once solution would be to publish a single .json file containing all of the types in the schema, eliminating the need to do $ref resolution. A single file is also more convenient than a directory, since there's no need to zip it (and unzip it after download). Of course the downside is that one big file with all the types in it is cumbersome to maintain, but.. 1. its not that bad 2. we can improve things with tooling (i.e. lexographical sorting so types are where you expect them).
…y-configuration into yaml-source-of-truth
Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com>
move compile-schema into a common file
…y-configuration into yaml-source-of-truth
Alternative solution for #398 based off conversation in #407 and #400
Idea:
meta_schema_types.yamlinto the schema files so everything is in one placeIf we like this idea I would follow up with a PR to merge
meta_schema_types.yamlinto the source YAML files, and update all project tooling, documentation, etc.