[BUG] Python client fails on validating nullable field
Created by: nmuesch
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
It looks like any nullable
schema that also contains a max/min (any validation component) causes check_validations to fail with something like:
File "model_utils.py", line 752, in check_validations
'max_length' in current_validations and
TypeError: '>' not supported between instances of 'NoneType' and 'int'
openapi-generator version
Using openapigenerator at commit 41851b45 (pretty recent master)
OpenAPI declaration file content or url
id:
example: 123456
format: int32
maximum: 2147483647
readOnly: true
nullable: true
type: integer
The offending line seems to fail around here - https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/python/python-experimental/model_utils.mustache#L495-L496
Generation Details
Steps to reproduce
Generating the python client with an object of the above schema, then calling the endpoint (where the endpoint can return None, or not return that field at all), will reproduce this issue.
Related issues/PRs
I couldn't find a similar report
Suggest a fix
I'm not sure if it'd be enough check for None and return at the beginning of the check_validations method, or if we'd need to pass allowed_values (or a similar field) around a bit to see if None is an OK value for that specific input.