JackKCWong / go-jsonschemate

Infers a json schema from a json object

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jsonschemate

Infer a jsonschema from a json file

usage

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"
    ]
}

how it works

It converts a json to Go struct and then generates a schema from the Go struct.

caveats

  • It marks all properties as required
  • It doesn't do well with "null" values

About

Infers a json schema from a json object

License:MIT License


Languages

Language:Go 100.0%