question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bad code gen for integer with exclusiveMinimum/exclusiveMaximum

See original GitHub issue

Given a schema like

properties:
  period:
    exclusiveMaximum: true
    exclusiveMinimum: true
    maximum: 1209600
    minimum: 60
    type: integer
  type:
    enum:
    - set-retention-period
required:
- type

the generated code includes this clause for period

        if "period" in data_keys:
            data_keys.remove("period")
            data_period = data["period"]
            if not isinstance(data_period, (int)) and not (isinstance(data_period, float) and data_period.is_integer()) or isinstance(data_period, bool):
                raise JsonSchemaException("data.period must be integer")
            if isinstance(data_period, (int, float)):
                if data_period <= 60:
                    raise JsonSchemaException("data.period must be bigger than 60")
            if isinstance(data_period, (int, float)):
                if data_period >= 1209600:
                    raise JsonSchemaException("data.period must be smaller than 1209600")
            if isinstance(data_period, (int, float)):
                if data_period <= True:
                    raise JsonSchemaException("data.period must be bigger than True")
            if isinstance(data_period, (int, float)):
                if data_period >= True:
                    raise JsonSchemaException("data.period must be smaller than True")

the bottom two comparison checks shouldn’t be there, ie there’s no reason to be comparing this to the integer value of True.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kapiltcommented, Apr 16, 2019

oh… i see what you mean, thanks

0reactions
manugarricommented, Sep 3, 2019

Oh, that makes a lot of sense!, thanks a ton!.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data Types - Swagger
OpenAPI has two numeric types, number and integer , where number includes ... The word “exclusive” in exclusiveMinimum and exclusiveMaximum ...
Read more >
Json schema validation error - Stack Overflow
Therefore you receive an error about wrong type. JSON schema type MUST be single value or array of such strings: "array","boolean","integer" ...
Read more >
Understanding JSON Schema
In JSON Schema Draft 4, exclusiveMinimum and exclusiveMaximum work differently. There they are boolean values, that indicate whether minimum ...
Read more >
schema-to-yup - npm
exclusiveMinimum : 0,. required: true ... This would generate the following Yup validation schema: ... integer; moreThan ( exclusiveMinimum ) ...
Read more >
Schema | REST API Handbook
{ "shouldBeArray": 'LOL definitely not an array', "shouldBeInteger": ['lolz', ... JSON Schema also allows using the exclusiveMinimum and exclusiveMaximum ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found