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
  • #12623
Closed
Open
Issue created Jun 17, 2022 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG][Python] date-time default value is ignored in python-legacy client

Created by: QuentinBrosse

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

With the python-legacy generator, a default value set on a string field with a date-time format is ignored in the generated python client.

openapi-generator version

v6.0.0 (and latest)

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  description: test
  version: 0.0.0
  title: test
servers:
  - url: /api
paths:
  /collector/v1/packages_block:
    post:
      operationId: postPackagesBlock
      requestBody:
        content:
          application/json:
            schema:
              "$ref": '#/components/schemas/PackagesBlock'
      responses:
        200:
         description: Successful request
components:
  schemas:
    PackagesBlock:
      type: object
      properties:
        package:
          "$ref": '#/components/schemas/PackagesBlockPackage'
    PackagesBlockPackage:
      type: object
      properties:
        installation_date:
          type: string
          format: date-time
          description: Date and time of package installation.
          example: "1995-08-22T05:08:28Z"
          default: "1995-08-22T05:08:28Z"
Generation Details
docker run --rm openapitools/openapi-generator-cli:latest generate \
	--input-spec /specification/openapi.yml \
	--generator-name python-legacy \
	--library asyncio \
	--package-name  ${CLIENT_PACKAGE_NAME} \
	--additional-properties packageName=${CLIENT_PACKAGE_NAME} \
	--additional-properties packageVersion=${CLIENT_VERSION} \
	--output ${GENERATED_CLIENT}
Steps to reproduce
  1. Execute openapitools/openapi-generator-cli:latest generate on the provided specification

  2. Check the generated PackagesBlockPackage client model and focus on the __init__ method:

    class PackagesBlockPackage(object):
        # [...]
    
        def __init__(self, installation_date=None, local_vars_configuration=None):  # noqa: E501
            """PackagesBlockPackage - a model defined in OpenAPI"""  # noqa: E501
            if local_vars_configuration is None:
                local_vars_configuration = Configuration.get_default_copy()
            self.local_vars_configuration = local_vars_configuration
    
            self._installation_date = None
    
            self.installation_date = installation_date

Notice that the installation_date parameter of PackagesBlockPackage.__init__ is defaulted to Null instead of 1995-08-22T05:08:28Z.

Related issues/PRs

N/A

Suggest a fix

In progress. I'll do my best without Java knowledge.

Assignee
Assign to
Time tracking