You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An increasingly popular way to verify that a json document conforms to a specification is to provide a json schema to validate it. The benefit of json schemas is that there is already a lot of tools to generate web UIs, lint, validate, etc.
Since yaml and json are compatible, it is possible to create a json schema to validate a yaml file. For example, let us consider this example from the documentation:
So it looks like confuse templates and json schemas can be used to achieve similar things. Now, what a json schema cannot do is resolve the configuration values from various places.
Given the amount of standardization that json schemas benefit from, I think it would be interesting to try to bring them in confuse. Therefore, I am wondering: would it be possible to generate a confuse template from a json schema? Looking at the spec, it looks very much possible.
As a user, I think it would be neat if confuse would offer a way to build a template from a json schema. Reusing the previous example, here is how I imagine it could work:
importconfusesource=confuse.YamlSource('servers_example.yaml')
config=confuse.RootView([source])
schema= {
"type": "object",
"properties": {
"server": {
"type": "array",
"items": {
"type": "object",
"properties": {
"host": {
"type": "string"
},
"port": {
"type": "integer",
"default": 80
}
}
}
}
}
}
# new function creating a template from a json schematemplate=confuse.from_jsonschema(schema)
valid_config=config.get(template)
What do you think? Would you be interested in supporting json schemas?
Cheers,
Christophe-Marie
The text was updated successfully, but these errors were encountered:
Hi,
An increasingly popular way to verify that a json document conforms to a specification is to provide a json schema to validate it. The benefit of json schemas is that there is already a lot of tools to generate web UIs, lint, validate, etc.
Since yaml and json are compatible, it is possible to create a json schema to validate a yaml file. For example, let us consider this example from the documentation:
Currently, confuse offers a way to validate this configuration based on a template:
With a json schema, the same configuration can be validated in a similar fashion:
So it looks like confuse templates and json schemas can be used to achieve similar things. Now, what a json schema cannot do is resolve the configuration values from various places.
Given the amount of standardization that json schemas benefit from, I think it would be interesting to try to bring them in confuse. Therefore, I am wondering: would it be possible to generate a confuse template from a json schema? Looking at the spec, it looks very much possible.
As a user, I think it would be neat if confuse would offer a way to build a template from a json schema. Reusing the previous example, here is how I imagine it could work:
What do you think? Would you be interested in supporting json schemas?
Cheers,
Christophe-Marie
The text was updated successfully, but these errors were encountered: