Open rc65 opened 1 month ago
I am trying to generate a Python client from a Swagger 2.0 schema but the generated types are not what I expect them to be.
I am using version 7.8.0-SNAPSHOT but have also downloaded and tried the 8.0.0-SNAPSHOT.
7.8.0-SNAPSHOT
8.0.0-SNAPSHOT
swagger: '2.0' paths: /workflows/start: post: parameters: - in: body name: body required: true schema: $ref: '#/definitions/PayloadDefinition' responses: '200': description: Request succeeded definitions: PayloadDefinition: properties: ArrayArgs: type: array items: {}
If I convert this to what I think is an equivalent OpenAPI 3.0.3 schema like:
openapi: '3.0.3' info: title: Example API version: 1.0.0 paths: /workflows/start: post: requestBody: content: application/json: schema: $ref: '#/components/schemas/PayloadDefinition' responses: '200': description: Request succeeded components: schemas: PayloadDefinition: properties: ArrayArgs: type: array items: {}
the generated type is correct, i.e. array_args: Optional[List[Any]] = Field(default=None, alias="ArrayArgs").
array_args: Optional[List[Any]] = Field(default=None, alias="ArrayArgs")
openapi-generator generate -i ./schema.yaml -g python -o ./client
client/openapi_client/models/payload_definition.py
array_args: Optional[List[Dict[str, Any]]] = Field(default=None, alias="ArrayArgs")
The type annotation should be Optional[List[Any]]
Optional[List[Any]]
N/A
The generated type should be a list of Any.
Any
Tagging @multani as a member of the Python generator technical committee for visibility.
Bug Report Checklist
Description
I am trying to generate a Python client from a Swagger 2.0 schema but the generated types are not what I expect them to be.
openapi-generator version
I am using version
7.8.0-SNAPSHOT
but have also downloaded and tried the8.0.0-SNAPSHOT
.OpenAPI declaration file content or url
If I convert this to what I think is an equivalent OpenAPI 3.0.3 schema like:
the generated type is correct, i.e.
array_args: Optional[List[Any]] = Field(default=None, alias="ArrayArgs")
.Generation Details
openapi-generator generate -i ./schema.yaml -g python -o ./client
Steps to reproduce
client/openapi_client/models/payload_definition.py
The type annotation should be
Optional[List[Any]]
Related issues/PRs
N/A
Suggest a fix
The generated type should be a list of
Any
.