OpenAPITools / OpenAPITools/openapi-generator
[BUG] [PYTHON] Malformed type hints on 6.3.0-SNAPSHOT with 303 status response
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
Clients are generated with syntax errors using the spec provided.
Sample of code with syntax errors:
class ThingDownload(BaseApi):
# this class is used by api classes that refer to endpoints with operationId fn names
@typing.overload
def thing_download(
self,
path_params: RequestPathParams = frozendict.frozendict(),
accept_content_types: typing.Tuple[str] = _all_accept_content_types,
stream: bool = False,
timeout: typing.Optional[typing.Union[int, typing.Tuple]] = None,
skip_deserialization: typing_extensions.Literal[False] = ...,
) -> typing.Union[
]: ...
It is not valid for this typing.Union to be empty, as shown at import time:
E ) -> typing.Union[
E ^
E SyntaxError: expected ':'
openapi-generator version
openapi-generator-cli 6.3.0-SNAPSHOT
commit : 188c39d
built : 2022-11-11T16:58:19-05:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
OpenAPI declaration file content or url
Gist: https://gist.github.com/syntaxaire/9e584c63ac4ce71c7eda882a4d6837dc
Generation Details
java -jar openapi-generator-cli.jar generate --global-property skipFormModel=false -i empty-union.json -g python -o empty-union
Steps to reproduce
- Download the spec from the provided gist.
- Use the latest git version with the command line above to generate the client
- Install the client and run its unit tests, the above syntax error will be shown when imported
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 with the empty-union.json specification from the linked gist and reproduce the issue using the documented openapi-generator CLI command with the Python generator. Inspect the generated client's type hints, then run its unit tests; done means the client imports and tests run without the reported SyntaxError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100