OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Python] nullable reference not generating any_of_x
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)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
I'm still having problems with the nullable reference. I've used the anyOf trick which passes the specification validation, but fails at runtime because the models.any_of_tier module is not generated.
ModuleNotFoundError: No module named '<my_package>.openapi_server.models.any_of_tier'
openapi-generator version
I just pulled the latest docker image.
OpenAPI declaration file content or url
tier:
anyOf:
- $ref: '#/components/schemas/Tier'
nullable: True
(for YAML code) or
Command line used for generation
docker run --rm -v ${BUILD_DIR}:/local openapitools/openapi-generator-cli generate
-i local/${ENDPOINT_SPEC}
-g python-flask
-o /local
Steps to reproduce
submit a request with tier: null
Related issues/PRs
https://github.com/OAI/OpenAPI-Specification/issues/1368
Suggest a fix
I've also tried:
alllOf and get
validation error: None is not of type 'object'
which makes sense because tier doesn't exist.
oneOf generates the same error as anyOf.
models.one_of_tier
ModuleNotFoundError: No module named '<my_package>.openapi_server.models.one_of_tier'
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 issue's Docker command with the shown OpenAPI declaration and the python-flask generator, then inspect the generated models and the runtime error for tier: null. The fix is done when a nullable anyOf reference generates the needed model handling and a request containing tier: null no longer raises ModuleNotFoundError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, openapi, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100