swagger-api / swagger-api/swagger-codegen
[PYTHON] Problem with Discriminator
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am trying to use polymorphism with discriminator
Swagger-codegen version
3.0.36
Swagger declaration file content or url
"discriminator": {
"propertyName": "type",
"mapping": {
"individualApplication": "#/definitions/IndividualApplication",
"businessApplication": "#/definitions/BusinessApplication",
"trustApplication": "#/definitions/TrustApplication"
}
}
Command line used for generation
java -jar swagger-codegen-cli-3.0.36.jar generate -i openapi.json -l python -o /output
Error
AttributeError: module 'swagger_client.models' has no attribute '#/components/schemas/IndividualApplication'
Suggest a fix/enhancement
I need the attribute to be "IndividualApplication" without the 'swagger_client.models'
or maybe try to ignore #/components/schemas/
Am I right or am I doing something wrong?
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 swagger-codegen-cli-3.0.36.jar, the supplied OpenAPI discriminator mapping, and the -l python command. Inspect how the generated swagger_client.models lookup handles the mapping references; done means the generated client resolves IndividualApplication, BusinessApplication, and TrustApplication without treating the JSON reference as an attribute name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, 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