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 support for jsonschema export similar to openapi-v3 #898

Open
peschmae opened this issue Mar 25, 2024 · 5 comments
Open

Add support for jsonschema export similar to openapi-v3 #898

peschmae opened this issue Mar 25, 2024 · 5 comments
Assignees
Labels
enhancement This issue is a feature request

Comments

@peschmae
Copy link
Contributor

Describe the problem/challenge you have
Most text editors use json schema, to autocomplete and validate YAML files. To make it easier to the users, to write YAML files based on a YTT schema, it would be great to have a way to create the json schema from a YTT file, similar to the openapi schema that is currently implemented.

Describe the solution you'd like
Support for json schema as a output option for ytt -f schema.yaml --data-values-schema-inspect --output

Anything else you would like to add:
During kubecon 2024, the talk Developers demand UX for K8s highlighted that YAML validation & auto-completion seems to be one of the main struggles developers face when working with Kubernetes.

Using YTT and it's schemas, could help alleviate that issue.


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@peschmae peschmae added carvel triage This issue has not yet been triaged for relevance enhancement This issue is a feature request labels Mar 25, 2024
@prembhaskal prembhaskal self-assigned this Mar 26, 2024
@peschmae
Copy link
Contributor Author

After diggin in to the openapi schema generation for #897 I think this shouldn't be too hard to implement, as the property attributes are mostly identical, and a lot of the code could be reused.

From a quick glance at https://swagger.io/docs/specification/data-models/keywords/ the biggest difference is that type is a list, and nullable isn't an attribute, but needs to be added to the type list.

@prembhaskal Let me know if I should draft a pull request for this.

@peschmae
Copy link
Contributor Author

I found some time today, and threw a quick and dirty approach together in a feature branch: https://github.com/peschmae/ytt/tree/feat/jsonschema

It would still need a refactoring, to reduce duplicate code shared with the openschema export, but it already converts into a valid schema that is properly interpreted by vscode.

@prembhaskal
Copy link
Contributor

@peschmae I am bit stuck with other stuff, but I can review it over weekend. but you can go ahead and put up a PR if you want some early eyes on it.

@100mik @sethiyash PTAL when you get time.

@prembhaskal prembhaskal removed their assignment Apr 6, 2024
@prembhaskal
Copy link
Contributor

I am unable to check it still, so removed assignee.

@renuy renuy removed the carvel triage This issue has not yet been triaged for relevance label Apr 19, 2024
@renuy renuy assigned renuy and cppforlife and unassigned renuy Apr 19, 2024
@renuy
Copy link

renuy commented Apr 19, 2024

@cppforlife @100mik Please take a look at this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a feature request
Projects
Status: No status
Development

No branches or pull requests

4 participants