OpenAPITools / OpenAPITools/openapi-generator
[BUG][Python] date-time default value is ignored in python-legacy client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
-
Execute
openapitools/openapi-generator-cli:latest generateon the provided specification -
Check the generated
PackagesBlockPackageclient 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided OpenAPI specification with the python-legacy generator and asyncio library, then inspect the generated PackagesBlockPackage.__init__ method. Compare the installation_date default with the declared date-time value; done means the generated client preserves that default instead of using null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100