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] Deserialize json vendor extensions broken since 7.7.0 #19285

Closed
5 of 6 tasks
kevinferrare opened this issue Aug 1, 2024 · 1 comment · Fixed by #19317
Closed
5 of 6 tasks

[BUG][PYTHON] Deserialize json vendor extensions broken since 7.7.0 #19285

kevinferrare opened this issue Aug 1, 2024 · 1 comment · Fixed by #19317

Comments

@kevinferrare
Copy link
Contributor

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

Since this commit, generated python api_client cannot handle deserializing json with a content type that does not start with application/json.
For example vendor extensions like application/vnd.amadeus+json

https://www.iana.org/assignments/media-types/application/vnd.amadeus+json

6ae8a8f

openapi-generator version

7.7.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Test
  version: '1.0'
paths:
  '/test':
    get:
      requestBody:
        content:
          application/vnd.amadeus+json:
            schema:
              type: object
              title: TestObject
              properties:
                id:
                  type: string
      responses:
        '200':
          description: OK
Generation Details

java -jar openapi-generator-cli-7.8.0-SNAPSHOT.jar generate -o ./generated -i ./test-api.yaml -g python

Steps to reproduce

Save the API declaration in a file and generate it.

When calling test_get() method, it fails with an exception because it doesnt understand application/vnd.amadeus+json is json:

ApiException: (0) Reason: Unsupported content type: application/vnd.amadeus+json;charset=UTF-8
Related issues/PRs

None I could find

Suggest a fix

In the api_client files updated by the commit I mention, Replace:

elif content_type.startswith("application/json"):

With:

elif content_type.startswith("application/json") or content_type.endswith("+json"):
@fa0311
Copy link
Contributor

fa0311 commented Aug 7, 2024

related: #18800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants