Open jbowen93 opened 3 years ago
The example docs for threads here gives the example schema:
const schema = { $schema: 'http://json-schema.org/draft-07/schema#', title: 'Person', type: 'object', properties: { _id: { type: 'string' }, name: { type: 'string' }, missions: { type: 'number', minimum: 0, exclusiveMaximum: 100, }, }, }
This example returns the following error:
json: cannot unmarshal number into Go struct field Type.properties.exclusiveMaximum of type bool
because the json.Marshal(config.Schema) call here uses the CollectionConfig type here which uses https://github.com/alecthomas/jsonschema which has this schema type where both exclusiveMaximum and exclusiveMinimum are of type Bool, matching http://json-schema.org/draft-04/schema#.
json.Marshal(config.Schema)
exclusiveMaximum
exclusiveMinimum
Bool
There is an issue from January 2020 requesting draft-07 support here.
Modifying the Schema to:
... missions: { type: 'number', minimum: 0, maximum: 100, exclusiveMaximum: true, }
results in a different error:
Invalid type. Expected: number, given: exclusiveMaximum
removing exclusiveMaximum entirely works as expected.
The easiest fix is probably to remove any usage of exclusiveMaximum or exclusiveMinimum from the docs and perhaps adding a note that the JSON schema should match draft-04.
The example docs for threads here gives the example schema:
This example returns the following error:
because the
json.Marshal(config.Schema)
call here uses the CollectionConfig type here which uses https://github.com/alecthomas/jsonschema which has this schema type where bothexclusiveMaximum
andexclusiveMinimum
are of typeBool
, matching http://json-schema.org/draft-04/schema#.There is an issue from January 2020 requesting draft-07 support here.
Modifying the Schema to:
results in a different error:
removing
exclusiveMaximum
entirely works as expected.The easiest fix is probably to remove any usage of
exclusiveMaximum
orexclusiveMinimum
from the docs and perhaps adding a note that the JSON schema should match draft-04.