-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Python client: response parsing fails for array of anyOf items #6546
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
@hleb-albau have you tried using the
|
@spacether Btw, I tried online swagger editor and generate another version on client. Seems it is generated by swagger-generator. Using that client I get lucky with response parsing. But in the middle of de-serialization anyOf types were lost and replaces by raw dict. I should prepare some full example, need some time. |
Ah, I was missing that this was an array model. I though that it was an object type model. Can you provide the referenced anyOf models?
We don't yet have code coverage of this use case in python-experimental. |
In the short term, you could make an anyOf model which contains your anyOf definition. Then in your array model, just $ref to your new anyof model. That should work in python-experimental. We also had a PR that just landed which creates arrayModels in python-experimental so
|
This work in |
python-experimental became the default |
Bug Report Checklist
Description
If openapi definition contains model of type array with anyOf items description, generated Python client can't parse request from server. Generated model has openapi_types with next type
list[AnyOfFirstSecondThird]
. During response parsing client takes one by one list items and try to de-serialize to non existing type klass AnyOfFirstSecondThird. Parsing fails atklass = getattr(openapi_client.models, klass)
line with next error -module 'openapi_client.models' has no attribute 'AnyOfFirstSecondThird'
openapi-generator version
latest master, 5.0.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/docs/openapi.yml -g python -o /local/clients/python
Steps to reproduce
Related issues/PRs
Suggest a fix
The text was updated successfully, but these errors were encountered: