2022-10-06 08:23:55 +01:00
|
|
|
# go-jsonschema
|
|
|
|
|
2022-10-07 11:30:45 +01:00
|
|
|
A [JSON schema] code generator for Go.
|
2022-10-06 08:23:55 +01:00
|
|
|
|
2022-10-10 12:16:08 +01:00
|
|
|
JSON schema draft 2020-12 is supported.
|
|
|
|
|
2023-11-24 18:31:57 +00:00
|
|
|
This project is a fork of https://git.sr.ht/~emersion/go-jsonschema with the following changes:
|
|
|
|
|
|
|
|
- Add the option to add multi-line comments at the top of the generated file.
|
|
|
|
- Add the option to name the top-level type.
|
|
|
|
|
2022-10-06 08:23:55 +01:00
|
|
|
## Usage
|
|
|
|
|
2023-11-24 18:31:57 +00:00
|
|
|
```
|
|
|
|
go-jsonschema -s <schema> -o <output>
|
|
|
|
```
|
2022-10-06 08:23:55 +01:00
|
|
|
|
2022-10-07 10:55:30 +01:00
|
|
|
One Go type per definition will be generated.
|
|
|
|
|
|
|
|
- `int64` is used for `"type": "integer"`.
|
|
|
|
- `json.Number` is used for `"type": "number"`.
|
|
|
|
- Go structs are generated for objects with `"additionalProperties": false`.
|
|
|
|
- `json.RawMessage` is used when a value can have multiple types. Helpers are
|
2022-10-07 11:10:12 +01:00
|
|
|
generated for `allOf`, `anyOf`, `oneOf`, `then`, `else` and `dependantSchemas`
|
|
|
|
which are references.
|
2022-10-07 10:55:30 +01:00
|
|
|
|
2023-02-16 15:31:30 +00:00
|
|
|
## Contributing
|
|
|
|
|
|
|
|
Report bugs and send patches to the [mailing list]. Discuss in [#emersion] on
|
|
|
|
Libera Chat.
|
|
|
|
|
2022-10-06 08:23:55 +01:00
|
|
|
## License
|
|
|
|
|
|
|
|
MIT
|
2022-10-07 11:30:45 +01:00
|
|
|
|
|
|
|
[JSON schema]: https://json-schema.org/
|
2023-02-16 15:31:30 +00:00
|
|
|
[mailing list]: https://lists.sr.ht/~emersion/public-inbox
|
|
|
|
[#emersion]: ircs://irc.libera.chat/#emersion
|