Skip to content

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

Closed
@kevinferrare

Description

@kevinferrare

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"):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions