quicktype
quicktype copied to clipboard
[FEATURE]: Allow CLI users to specify alternate top-level schema (json schema draft)
Context (Input, Language)
Using the CLI to get a schema file from a json file.
Input Format: JSON Output Language: Schema
Description
I want to make it easy for my team to document their services' message structure with json schema. I am hoping they can use the quicktype cli to do this, given an example message as a json file. However, I want use to use the 2020-12 draft of json schema. We have hundreds of services that each send a few different kinds of messages, so it's quite a bit of work to do manually.
I realize they will need to edit the resulting file anyway, to tweak formats and required fields and such, but I would prefer if they didn't have to remember to update the top-level $schema as well.
Current Behaviour / Output
❧ quicktype --lang schema --src-lang json -o pubsub-topic-name.schema.json pubsub-topic-name.sample.json
❧ head -n2 pubsub-topic-name.schema.json
{
"$schema": "http://json-schema.org/draft-06/schema#",
Proposed Behaviour / Output
❧ quicktype --lang schema --src-lang json --schema draft/2020-12 -o pubsub-topic-name.schema.json pubsub-topic-name.sample.json
❧ head -n2 pubsub-topic-name.schema.json
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
... or something like that for the option. Maybe it would be better to provide the full URL. I don't know what the possibilities are.
Solution
???
Alternatives
Relying on humans to remember to change it. Humans are not always good at such things.