OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
20.74k stars 6.32k forks source link

[BUG] [python-pydantic-v1]The response_types_map does not include responses starting with string types '1XX' and '2XX', so this syntax cannot achieve the desired effect: response_type = response_types_map.get(str(response_data.status)[0] + "XX", None). #18011

Open caojieliyu opened 4 months ago

caojieliyu commented 4 months ago

Bug Report Checklist

Description

The response_types_map does not include responses starting with string types '1XX' and '2XX', so this syntax cannot achieve the desired effect: response_type = response_types_map.get(str(response_data.status)[0] + "XX", None).

api_client.py Lines of code

231 response_type = response_types_map.get(str(response_data.status)[0] + "XX", None)

eg:

response_data.status= 200

response_types_map ={'201':'AAAResponse}

response_type =None --> return_data =None

openapi-generator version

7.3.0

OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
wing328 commented 4 months ago

can you try python client generator as well to see if the same issue occurs?

can you also share a spec to reproduce the issue?

fa0311 commented 4 months ago
paths:
  /aaa:
    get:
      responses:
        "2XX":
          description: OK

Defining the schema in this way will work, but I am not sure if this is the syntax defined by OpenAPI. Non-explicit parsing should not be done because type safety will not be ensured.