Skip to content

add json schema for model config #48

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caozhuozi
Copy link
Contributor

@caozhuozi caozhuozi commented Apr 12, 2025

fix: #46

@bergwolf
Copy link
Contributor

Would you add a schema for all the spec? It makes sense to add them in one shot, better having a script to auto-generate the go files.

@caozhuozi
Copy link
Contributor Author

HI, @bergwolf Thank you for reviewing the PR!

Would you add a schema for all the spec?

Are you referring to the manifest specification? Initially, I thought yes, but then I wondered given that the manifest spec itself follows the OCI manifest format, would it be redundant?

Hope I understand the question correctly. 🙇

@bergwolf
Copy link
Contributor

bergwolf commented Apr 21, 2025

@caozhuozi I'm mostly considering auto-generating .go files from the json schema. Can we do it w/ the current schema?

@caozhuozi
Copy link
Contributor Author

I'm mostly considering auto-generating .go files from the json schema. Can we do it w/ the current schema?

I'm not sure if this behavior is consistent with the current OCI image-spec. I'll look into it and confirm in the following comment.

Im also thinking generating a JSON schema from Go structs might also be a reasonable alternative? What do you think?

@caozhuozi
Copy link
Contributor Author

caozhuozi commented Apr 21, 2025

@bergwolf

I'm mostly considering auto-generating .go files from the json schema. Can we do it w/ the current schema?

I've checked out the image-spec JSON schema files, and it looks like they were added manually. There doesn't seem to be any auto generation in both directions.

For example, see the commit history of config-schema.json: https://github.com/opencontainers/image-spec/commits/main/schema/config-schema.json

The only automation thing I've found related to the JSON schema files is a validation process. If you look at the Makefile and the spec_test.go, you can see it validates some example JSONs against the schema using the github.com/santhosh-tekuri/jsonschema/v5 package (see https://github.com/opencontainers/image-spec/blob/main/schema/validator.go#L27).

Of course, I'm not saying generating code wouldn't be a good idea. ;-)

@bergwolf
Copy link
Contributor

@caozhuozi I see. Thanks for the details! Then, could you add the validation tests so that we make sure the specs-go aligns with the schema? It also ensures that we involve the spec and schema together in future changes.

@caozhuozi
Copy link
Contributor Author

@bergwolf
Sure. I will.

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.

Do we need a json schema?
2 participants