Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #7797
Closed
Open
Issue created Oct 23, 2020 by Administrator@rootContributor0 of 6 checklist items completed0/6 checklist items

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

Assignee
Assign to
Time tracking