OpenAPITools / OpenAPITools/openapi-generator
[BUG] Path issues when generating python client via docker
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
I am generating a python client with the attached specs, and getting an incomplete/broken output.
openapi-generator version
I am using openapi-generator-cli:latest-release
https://hub.docker.com/layers/openapitools/openapi-generator-cli/latest-release/images/sha256-fc570971c1ca62fac829aba7d7d735efd580293adecdd2ccae21094904bc29e6?context=explore
OpenAPI declaration file content or url
openapispecs.yml
---
openapi: 3.0.2
info:
title: my-service
description: Service description
version: 1.0.0
paths:
"/":
get:
tags:
- infra
summary: Hello World
description: |-
Hello World with an optional GET param 'name'.
Args:
name: Str passed as URL parameter
identity_uuid: uuid
Returns:
Response: PlainTextResponse containing "hello 'name'" text
operationId: hello_world__get
parameters:
- required: false
schema:
title: Name
type: string
default: world
name: name
in: query
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
"/hello/":
get:
tags:
- infra
summary: Health
description: Check the health of the application.
operationId: health_hello__get
responses:
'200':
description: Successful Response
content:
application/json:
schema:
"$ref": "#/components/schemas/HelloResponse"
components:
schemas:
HTTPValidationError:
title: HTTPValidationError
type: object
properties:
detail:
title: Detail
type: array
items:
"$ref": "#/components/schemas/ValidationError"
HelloResponse:
title: HelloResponse
type: object
properties:
status:
title: Status
type: string
default: ok
description: Simple model with OK status.
ValidationError:
title: ValidationError
required:
- loc
- msg
- type
type: object
properties:
loc:
title: Location
type: array
items:
anyOf:
- type: string
- type: integer
msg:
title: Message
type: string
type:
title: Error Type
type: string
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest-release generate \
-i /local/openapispecs.yml \
-g python \
-o /local/out/python
Output Example
I would expect the second line to have a complete import statement and for PathValues.SOLIDUS to have a value.
python/openapi_client/apis/path_to_api.py
import typing_extensions
from openapi_client.paths import PathValues
from openapi_client.apis.paths. import
from openapi_client.apis.paths.hello_ import Hello
PathToApi = typing_extensions.TypedDict(
'PathToApi',
{
PathValues.SOLIDUS: ,
PathValues.HELLO_: Hello,
}
)
path_to_api = PathToApi(
{
PathValues.SOLIDUS: ,
PathValues.HELLO_: Hello,
}
)
Steps to reproduce
When I run the same specs with the following command (using python-nextgen) I do not see this issue, and I am able to use the client.
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:latest-release generate \
-i /local/openapispecs.yml \
-g python-nextgen \
-o /local/out/python-nextgen
Related issues/PRs
Suggest a fix
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
Reproduce the issue with the Docker command and openapi specs shown, then inspect python/openapi_client/apis/path_to_api.py and compare the output with python-nextgen. Trace why the root path produces an incomplete import and empty PathValues.SOLIDUS entries; done means the generated Python client contains complete imports and usable values for both paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100