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

Provide JSON Schema for Configuration #22

Closed
Sherlouk opened this issue Apr 24, 2022 · 5 comments
Closed

Provide JSON Schema for Configuration #22

Sherlouk opened this issue Apr 24, 2022 · 5 comments

Comments

@Sherlouk
Copy link

Discussed this very briefly on Discord, but I think it would be really handy if we could provide a JSON schema document detailing every value supported in the configuration TOML file.

This would allow it to be used with plugins such as this one for VS Code which would provide code completion and validation of configurations improving the developer experience and hopefully reducing the number of issues developers face.

Taplo have stated they're happy for new schemas to be provided for native support, once the API is stabilised some, but even without pushing it upstream users can still utilise it if we host it on the documentation website 🙂

@stackotter
Copy link
Owner

I'm working on this now. I'm writing a generator that parses the configuration structs (along with their documentation comments) and converts that into a schema. It's going well and it'll be nice not having to put in effort to ensure that the schema stays up to date.

@stackotter
Copy link
Owner

I've basically got it working now, and it's pretty nifty. I tested it out and it works awesomely! Thanks for the great feature request 😅 It's on the main branch of the early access version if you want to check it out @Sherlouk (Bundler.schema.json in the root of the repo)

As an aside, I'm planning on just getting rid of the whole early access thing soon, but I haven't had time to figure out a few more things I want to get working before I do so.

@Sherlouk
Copy link
Author

Sherlouk commented Mar 6, 2023

main branch of the early access version

I don't think I actually have access any more? At least, I can't see it anywhere.

I've been using VSCode a bunch, and when it picks up on a schema and automatically validates my configuration files I absolutely love it. So definitely a big win here once fully available and submitted to the plugin linked above.

@stackotter
Copy link
Owner

It says you should have access, here's a direct link to the repo: https://github.com/swift-bundler/swift-bundler-early-access

@stackotter
Copy link
Owner

I've got the schema fulling working now, it should also always be up-to-date with the code too which is handy. The hover description shown for each property is taken from the property's documentation comment in the Swift code, and everything except for extra_plist_entries could be automatically generated (meaning I could generate schemas for old versions of the config too for backwards compat).

Unfortunately the schema for extra_plist_entries isn't very handy because I couldn't figure out a good way to express it in the JSON schema (plist value encoding/decoding is quite flexible).

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