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

Threads docs example fails due to exclusiveMaximum #282

Open
jbowen93 opened this issue Apr 16, 2021 · 0 comments
Open

Threads docs example fails due to exclusiveMaximum #282

jbowen93 opened this issue Apr 16, 2021 · 0 comments

Comments

@jbowen93
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant