Infer a jsonschema from a json file
go install github.com/JackKCWong/go-jsonschemate/...@latest
echo '{"hello": "world"}' | jsonsche [-yaml]
# or just
jsonsche input.json
output:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"hello": {
"type": "string"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"hello"
]
}
It converts a json to Go struct and then generates a schema from the Go struct.
- It marks all properties as required
- It doesn't do well with "null" values