Skip to content

Threads docs example fails due to exclusiveMaximum #282

@jbowen93

Description

@jbowen93

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#.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions