Go to file
Dan Anglin d01c4389be
fix: allow users to set multi-line comments
Main changes:

- Add an option to add multi-line comments at the top of the generated
  file.
- Add an option to name the top-level type.

Additional changes:

- Replace deprecated strings.Title with a custom title function.
- Refactor code based on linter feedback.
- Update LICENSE.
- Update go.mod and upgrade github.com/dave/jennifer from
  v1.5.1 to v1.7.0.
- Update documentation.
2023-11-24 18:31:57 +00:00
cmd/go-jsonschema fix: allow users to set multi-line comments 2023-11-24 18:31:57 +00:00
go.mod fix: allow users to set multi-line comments 2023-11-24 18:31:57 +00:00
go.sum fix: allow users to set multi-line comments 2023-11-24 18:31:57 +00:00
LICENSE fix: allow users to set multi-line comments 2023-11-24 18:31:57 +00:00
README.md fix: allow users to set multi-line comments 2023-11-24 18:31:57 +00:00
schema.go fix: allow users to set multi-line comments 2023-11-24 18:31:57 +00:00

go-jsonschema

A JSON schema code generator for Go.

JSON schema draft 2020-12 is supported.

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.

Usage

go-jsonschema -s <schema> -o <output>

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 generated for allOf, anyOf, oneOf, then, else and dependantSchemas which are references.

Contributing

Report bugs and send patches to the mailing list. Discuss in #emersion on Libera Chat.

License

MIT