3 ms·
is there a good tool or library to create a JSON Schema manually/programmatically ?
by albert_e 3y ago
is there a good tool or library to create a JSON Schema manually/programmatically ?
- mdaniel 3y agoIts autocomplete story is a mess, but https://github.com/Kong/insomnia#readme https://github.com/Kong/insomnia#readme at least allows one to visualize any schema authored in the document (it generates examples as well as a schema browser). It's possible that other OpenAPI tools behave similarly, I just happen to have the most hand's on with Insomnia for example: openapi: 3.0.0 info: title: this is my title description: a long description goes here version: v1 servers: - url: http://127.0.0.1:9090 description: the local server paths: /thingy: get: responses: "200": description: ok content: application/json: schema: $ref: '#/components/schemas/Thingy' components: schemas: Thingy: type: object properties: alpha: type: boolean as for the "create automatically," I'd guess that's a genuinely hard problem although if your example documents are simple/homogeneous enough you may get away with it ok: [{"alpha": true}, {"alpha":false}] problematic: [ {"alpha":{"beta": ["charlie", 3.1415, null]}}, {"alpha":[{"beta":null}]}, {"alpha": null} }
- beanaroo 3y agoI like to use zod for Typescript and Pydantic for python. https://github.com/StefanTerdell/zod-to-json-schema https://github.com/StefanTerdell/zod-to-json-schema https://docs.pydantic.dev/latest/usage/json_schema/ https://docs.pydantic.dev/latest/usage/json_schema/
- Fatal1ty 3y agoYou can find a suitable tool on the official website https://json-schema.org/implementations.html#schema-generators https://json-schema.org/implementations.html#schema-generato...