[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
-
Execute
openapitools/openapi-generator-cli:latest generate
on the provided specification -
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.