-
I would like to generate a jsonschema for a type that looks like:
However, What I would like is to have a way to transform
into
I can't define |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
OK, I found a way using reflector.Mapper = func(t reflect.Type) *jsonschema.Schema {
if reflect.TypeOf(intstr.IntOrString{}) == t {
return *jsonschema.Schema{
AnyOf: []*jsonschema.Schema{
{
Type: "string",
},
{
Type: "integer",
},
},
}
}
return nil
} One thing I noted is that I can't set the
instead of
but this is good enough for now. |
Beta Was this translation helpful? Give feedback.
OK, I found a way using
Reflector.Mapper
:One thing I noted is that I can't set the
Type
field to an array which doesn't match RFC draft-bhutton-json-schema-validation-00, section 6 as documented in thejsonschema.Schema
structure. As a result I getinstead of
but this is good enough for now.