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
)

func main() {
if len(os.Args) < 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the os.Args[0] the binary name itself? Should here be:

if len(os.Args) < 2 {
...
}


schemaJSON, err := json.MarshalIndent(schema, "", " ")
if err != nil {
log.Fatalf("Failed to marshal schema: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question, why using log.Fatalf? Usually fmt.Errorf() is the tool for error handling.

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.

2 participants