bad code gen for integer with exclusiveMinimum/exclusiveMaximum
See original GitHub issueGiven 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:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

oh… i see what you mean, thanks
Oh, that makes a lot of sense!, thanks a ton!.