-
Notifications
You must be signed in to change notification settings - Fork 33
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
JSON Schema #103
Comments
No, there's no schema available yet. But I was planning to do so. I need to look up how to do it, as I've never published any before |
Had a quick look on libs that can generate a schema (as a starting point):
|
Oh excellent! It means little maintenance. I like that 😉 Maybe we could also read the cobra flags from restic repo so they get added automatically (wishful thinking at best). |
This is not so hard, I think. Cobra generates manual pages that are quite well structured and not too difficult to parse. From there we can get commands, options and even descriptions. We'd only need to decide if that happens during build time (my preference), runtime or both (when manual pages exist already). Build time means we'd need to reference restic as dependency and build it. As a side effect this enables real integration tests. Knowing all restic commands and valid options would enable more than just json-schema, it also allows to validate the config, filter CLI args (e.g. replace the static list I added few days ago) and improve shell completion. |
Originally I was thinking about running the restic initialisation code and get the flags definition from cobra. But since it's all happening in a But you're right, it shouldn't be too difficult to parse the generated help for each command 👍🏻 |
Another option would be to let some tooling generate the initial json schema and then convert that into a CUE definition: https://cuelang.org/docs/usecases/datadef/ CUE can then export that in various formats and cue can even be reused to directly generate and validate the user's configuration. |
@creativeprojects: Had played a bit with restic command dictionary, here's a working prototype: #107 Let me know what you think then I'll try to add json-schema generation (and tests). |
@megamorf - Thanks for the hint 👍. We're looking for low maintenance solutions that continuously generate the information from code. cue-lang does look interesting and might have the ability to work with this use-case. However cue-lang to json-schema conversion is not ready cue-lang/cue#929. So we probably implement json-schema for now only. But if you want a cue schema you can still generated it from the json-schema using the cue tools. |
Yes please, it's really cool |
Squashed commits: Fixed: use correct decoder for GenericSection Fixed: restic version when flag/opt was removed Added notice how to gen the reference Fixed arg filtering and verbose arg with value Added extra examples for http hook headers Added failing test for inconsistent mixin-use Added "user_logged_on" to schedule privilege Added list-append to json-schema Add examples to global.default-command Added tests & cleanup Fixed flags `use-fs-snapshot` (win) and `verbose` Dynamically implement generic restic commands Removed manual config reference (is generated now) Generate JSON schema into documentation Added v2 mixins to JSON schema Initial support for "generate --json-schema" Initial support for "generate --config-reference" Moved PGP validation to go-selfupdate Added restic 1.4 (make generate-restic) Rebased & updated interfaces Initial profile info API Refactored restic, added versioning and install Include a lookup table for restic commands Adds build target "generate-restic-commands" to update the table
Squashed commits: Fixed: use correct decoder for GenericSection Fixed: restic version when flag/opt was removed Added notice how to gen the reference Fixed arg filtering and verbose arg with value Added extra examples for http hook headers Added failing test for inconsistent mixin-use Added "user_logged_on" to schedule privilege Added list-append to json-schema Add examples to global.default-command Added tests & cleanup Fixed flags `use-fs-snapshot` (win) and `verbose` Dynamically implement generic restic commands Removed manual config reference (is generated now) Generate JSON schema into documentation Added v2 mixins to JSON schema Initial support for "generate --json-schema" Initial support for "generate --config-reference" Moved PGP validation to go-selfupdate Added restic 1.4 (make generate-restic) Rebased & updated interfaces Initial profile info API Refactored restic, added versioning and install Include a lookup table for restic commands Adds build target "generate-restic-commands" to update the table
Now available in v0.21.0 👍🏻 |
Is there a JSON Schema for restic(profile) configuration files?
I see a JSON Schema especially useful if the editor supports it (e.g. VS Code), because the editing of a supported file is much more comfortable.
some examples from other projects you might know:
package.json
docker-compose.yaml
I couldn't find any information about an existing schema for resticprofile, so maybe there isn't one?
If this is not yet planned, this issue is more a feature request/enhancement idea.
The text was updated successfully, but these errors were encountered: