Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend JSON Schema method #51

Closed
samlown opened this issue Sep 29, 2022 · 1 comment
Closed

Extend JSON Schema method #51

samlown opened this issue Sep 29, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@samlown
Copy link
Contributor

samlown commented Sep 29, 2022

Jotting down this idea... there are a lot of requests to be able to support more advanced definitions which start getting really complex inside Go tags. The current JSONSchema() method helps support these cases, but has the tradeoff that you need to define the whole model.

A possible alternative could be to support an JSONSchemaExt(base *jsonschema.Schema) method that will generate the base schema for the Type as much as it can, then allow the type to override and add any additional fields, e.g.:

func (User) JSONSchemaExt(base *jsonschema.Schema) {
  base.AnyOf = &jsonschema.Schema{.....}
}
@pawndev
Copy link

pawndev commented Sep 29, 2022

Just wrote a simple version of what you said: #52

@samlown samlown closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants