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

Publish JSON schemas to validate configurations #407

Closed
yu-iskw opened this issue Apr 27, 2023 · 5 comments
Closed

Publish JSON schemas to validate configurations #407

yu-iskw opened this issue Apr 27, 2023 · 5 comments

Comments

@yu-iskw
Copy link

yu-iskw commented Apr 27, 2023

Motivation

As a lot of code editors enable us to validate files with JSON schemas, it would be great to publish JSON schemas of the allstar configurations. We can also publish them to https://json-schema.org/ .

@jeffmendoza
Copy link
Member

The configs are defined as go structs: https://github.com/ossf/allstar/blob/main/pkg/config/config.go#L33-L67

Do you know of any tools that can generate a schema from those?

@yu-iskw
Copy link
Author

yu-iskw commented May 11, 2023

@jeffmendoza It seems that I found a couple of tools/packages to generate a OpenAPI JSON schema from golang types. But, I haven't looked into them whether or not they support JSON schema 7.

@yu-iskw
Copy link
Author

yu-iskw commented May 15, 2023

@jeffmendoza We found another package looks nicer than what I shared before.

@yu-iskw
Copy link
Author

yu-iskw commented May 25, 2023

@jeffmendoza I did't find any tool to generate a JSON schema from the struct types, which follows the draft-7 specification of JSON schema.

  1. Generate the base JSON schema with go-jsonschema-generator
  2. Ask ChatGPT to convert it to follow the draft-7 spec.
  3. Manually remove something like required properties in the JSON schema

https://github.com/yu-iskw/allstar-jsonschema/blob/main/allstar-config.json

@yu-iskw
Copy link
Author

yu-iskw commented May 26, 2023

I figured out there is no perfect existing tool to generate JSON schemas from the definitions in golang. After all, I took advantage of ChatGPT to generate the JSON schemas.

https://github.com/yu-iskw/allstar-jsonschema

@yu-iskw yu-iskw closed this as completed May 26, 2023
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

No branches or pull requests

2 participants