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
  • #5813
Closed
Open
Issue created Apr 03, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] [flask-python] Optional date in query parameters results in dateutil error when None

Created by: Tohnmeister

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? 4.3.0
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
Description

I've recently extended my api with a query parameter of type string, format date. The parameter is optional. If the client does not fill in the parameter, it is None on the Python side, resulting in a parse error in dateutil:

Parser must be a string or character stream, not NoneType
openapi-generator version

4.3.0

OpenAPI declaration file content or url
paths:
  /events:
    get:
      tags:
        - events
      summary: "Get a list of all events"
      operationId: listEvents
      parameters:
        - $ref: '#/components/parameters/startDateParam'
components:
  parameters:
    startDateParam:
      name: startDate
      in: query
      description: Optional start date when querying date based items
      required: false
      schema:
        type: string
        format: date
Command line used for generation

openapi-generator generate -i ./api/openapi.yaml -g python-flask -o ./server/generated/ -c ./server/codegen/config.json

Steps to reproduce
  • Generate server with above yaml and command line
  • Start flask app
  • Go to Swagger UI (/ui)
  • Use events list call without filling in startDateParam
  • See error as shown above
Related issues/PRs

Couldn't find a related issue.

Suggest a fix

It should either be fixed in util.mustache by adding a check for the date being not None and otherwise returning None. Or something similar in controller.mustache.

Same goes for datetime I guess, but haven't tested that.

Assignee
Assign to
Time tracking