Skip to content
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 response fails to deserialize when $ref is used inside additionalProperties #7545

Closed
5 of 6 tasks
mks-m opened this issue Sep 29, 2020 · 5 comments
Closed
5 of 6 tasks

Comments

@mks-m
Copy link
Contributor

mks-m commented Sep 29, 2020

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

When response schema uses additionalProperties with $ref, the generated return type for request method is dict(str, list), which fails to deserialize because list doesn't specify item types.

openapi-generator version

4.3.1, 5.0.0-beta, master

OpenAPI declaration file content or url
components:
  schemas:
    a: {type: object, additionalProperties: {$ref: '#/components/schemas/b'}}
    b: {type: array, items: {type: string}}
paths:
  /z:
    get:
      responses:
        "200":
          description: z
          content: {application/json: {schema: {$ref: '#/components/schemas/a'}}}
Generation Details
rm -rf api
docker run --rm -i --user `id -u`:`id -g` -v `pwd`:/src \
  openapitools/openapi-generator-cli generate \
    -i /src/oapi.yaml \
    -g python \
    --package-name foo \
    -o /src/api
Steps to reproduce

Observe that:

cat api/foo/api/default_api.py | grep rtype

lists a return type dict(str, list).

Related issues

I would expect this to have been fixed by #7383, but it still fails on master.

cc @spacether

@auto-labeler
Copy link

auto-labeler bot commented Sep 29, 2020

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@spacether
Copy link
Contributor

spacether commented Sep 29, 2020

@keymone can you try using the python-experimental generator?
The fix that you referred to is for the python-experimental generator, not the python generator. They are different.

@mks-m
Copy link
Contributor Author

mks-m commented Sep 29, 2020

ah, i see. i didn't try experimental because there isn't a version tag (edit: with your fix in 7383) i can refer to for deterministic builds, so i switched to normal python. will try in a sec.

@mks-m
Copy link
Contributor Author

mks-m commented Sep 29, 2020

yeah, looks correct in experimental, sorry for bothering.

@mks-m
Copy link
Contributor Author

mks-m commented Sep 29, 2020

is there a schedule for beta releases?

@mks-m mks-m closed this as completed Sep 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants