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

Add json schema generation tool #59

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add json schema generation tool #59

wants to merge 5 commits into from

Conversation

romoh
Copy link
Contributor

@romoh romoh commented Jan 1, 2025

Add a cli that generates image customizer API json schema.
The generated schema file can be leveraged by other tools for API dependency and config validation.

Here's an example using it in VSCode for syntax validation:
image

Checklist

  • Tests added/updated
  • Documentation updated (if needed)
  • Code conforms to style guidelines

Signed-off-by: Roaa Sakr <[email protected]>
Signed-off-by: Roaa Sakr <[email protected]>
Signed-off-by: Roaa Sakr <[email protected]>
Signed-off-by: Roaa Sakr <[email protected]>
@romoh romoh marked this pull request as ready for review January 2, 2025 23:35
@romoh romoh requested a review from a team as a code owner January 2, 2025 23:35
toolkit/tools/imagecustomizerschemacli/go.mod Show resolved Hide resolved
@@ -66,6 +67,13 @@ func (s *PartitionSize) UnmarshalJSON(data []byte) error {
return parseAndSetPartitionSize(stringValue, s)
}

func (PartitionSize) JSONSchema() *jsonschema.Schema {
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll probably want a JSONSchema function on each type that has a UnmarshalYAML function.


BINARY_NAME := bin/imagecustomizerschemacli
GO_FILES := $(wildcard *.go)
SCHEMA_FILE := schema.json
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this schema.json be checked-in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I'm planning to but will do that in a separate change. The other change will include adding a github workflow to ensure this file is kept up to date with any change/PR.

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

Successfully merging this pull request may close these issues.

3 participants