feat: Add JSONSchemaHandle() with callbacks into the reflector #136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change provides
JSONSchemaHandle(ReflectorHandle)
, a hook in the same vein asJSONSchema() *jsonschema.Schema
, but with an api object to call back into the Reflector to get rhe schema handle for a type.This allows the user to manually create complex schemas, e.g. using OneOf, AllOf, etc, while referencing other types from within their codebase, and still getting the automatic code-generation from those structs/enums.
Usage:
Previously, in order to reference another type in a
JSONSChema() *Schema
function, you would have to do one of the following:$ref
in the schema, and ensure elsewhere in your code that you at some point visit the referenced type -- this is error prone, as it requires the reflector to visit your other structs at some pointNames are provisional -- I'm not very good at naming and willing to accept pretty much any suggestions