diff --git a/modules/openapi-generator/src/main/resources/python/api_client.handlebars b/modules/openapi-generator/src/main/resources/python/api_client.handlebars index 75d90cd2b1bb..da7e000a3a72 100644 --- a/modules/openapi-generator/src/main/resources/python/api_client.handlebars +++ b/modules/openapi-generator/src/main/resources/python/api_client.handlebars @@ -796,14 +796,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): """ pycharm needs this to prevent 'Unexpected argument' warnings diff --git a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml index 07241d9cba3e..518cf9497898 100644 --- a/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml @@ -1594,6 +1594,14 @@ paths: responses: '200': description: OK + '202': + description: header only + headers: + X-Rate-Limit: + description: calls per hour allowed by the user + schema: + type: string + format: number default: description: Unexpected error /fake/queryParamWithJsonContentType: diff --git a/samples/openapi3/client/3_0_3_unit_test/python/unit_test_api/api_client.py b/samples/openapi3/client/3_0_3_unit_test/python/unit_test_api/api_client.py index 102e967cf7b2..31022822e2be 100644 --- a/samples/openapi3/client/3_0_3_unit_test/python/unit_test_api/api_client.py +++ b/samples/openapi3/client/3_0_3_unit_test/python/unit_test_api/api_client.py @@ -800,14 +800,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): """ pycharm needs this to prevent 'Unexpected argument' warnings diff --git a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py index 6d9c2d44e6ab..63147d075d2b 100644 --- a/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py +++ b/samples/openapi3/client/features/dynamic-servers/python/dynamic_servers/api_client.py @@ -800,14 +800,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): """ pycharm needs this to prevent 'Unexpected argument' warnings diff --git a/samples/openapi3/client/petstore/python/docs/apis/tags/FakeApi.md b/samples/openapi3/client/petstore/python/docs/apis/tags/FakeApi.md index 1c4a29fc217d..62c09a71f2e3 100644 --- a/samples/openapi3/client/petstore/python/docs/apis/tags/FakeApi.md +++ b/samples/openapi3/client/petstore/python/docs/apis/tags/FakeApi.md @@ -884,6 +884,7 @@ Code | Class | Description ------------- | ------------- | ------------- n/a | api_client.ApiResponseWithoutDeserialization | When skip_deserialization is True this response is returned 200 | [ApiResponseFor200](#delete_coffee.ApiResponseFor200) | OK +202 | [ApiResponseFor202](#delete_coffee.ApiResponseFor202) | header only default | [ApiResponseForDefault](#delete_coffee.ApiResponseForDefault) | Unexpected error #### delete_coffee.ApiResponseFor200 @@ -893,6 +894,28 @@ response | urllib3.HTTPResponse | Raw response | body | Unset | body was not defined | headers | Unset | headers were not defined | +#### delete_coffee.ApiResponseFor202 +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +response | urllib3.HTTPResponse | Raw response | +body | Unset | body was not defined | +headers | ResponseHeadersFor202 | | +#### ResponseHeadersFor202 + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- +X-Rate-Limit | XRateLimitSchema | | optional + +# XRateLimitSchema + +calls per hour allowed by the user + +## Model Type Info +Input Type | Accessed Type | Description | Notes +------------ | ------------- | ------------- | ------------- +str, | str, | calls per hour allowed by the user | value must be numeric and storable in decimal.Decimal + + #### delete_coffee.ApiResponseForDefault Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- diff --git a/samples/openapi3/client/petstore/python/petstore_api/api_client.py b/samples/openapi3/client/petstore/python/petstore_api/api_client.py index db9cfc03613b..01a0cb7934ae 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/api_client.py +++ b/samples/openapi3/client/petstore/python/petstore_api/api_client.py @@ -800,14 +800,14 @@ class MediaType: @dataclass class ApiResponse: response: urllib3.HTTPResponse - body: typing.Union[Unset, Schema] - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset def __init__( self, response: urllib3.HTTPResponse, - body: typing.Union[Unset, typing.Type[Schema]], - headers: typing.Union[Unset, typing.List[HeaderParameter]] + body: typing.Union[Unset, Schema] = unset, + headers: typing.Union[Unset, typing.Dict[str, Schema]] = unset ): """ pycharm needs this to prevent 'Unexpected argument' warnings diff --git a/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.py b/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.py index b51db4af2b5d..06cf3e572a2a 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.py +++ b/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.py @@ -64,6 +64,33 @@ class ApiResponseFor200(api_client.ApiResponse): _response_for_200 = api_client.OpenApiResponse( response_cls=ApiResponseFor200, ) +XRateLimitSchema = schemas.DecimalSchema +x_rate_limit_parameter = api_client.HeaderParameter( + name="X-Rate-Limit", + style=api_client.ParameterStyle.SIMPLE, + schema=XRateLimitSchema, +) +ResponseHeadersFor202 = typing_extensions.TypedDict( + 'ResponseHeadersFor202', + { + 'X-Rate-Limit': XRateLimitSchema, + } +) + + +@dataclass +class ApiResponseFor202(api_client.ApiResponse): + response: urllib3.HTTPResponse + headers: ResponseHeadersFor202 + body: schemas.Unset = schemas.unset + + +_response_for_202 = api_client.OpenApiResponse( + response_cls=ApiResponseFor202, + headers=[ + x_rate_limit_parameter, + ] +) @dataclass @@ -78,6 +105,7 @@ _response_for_default = api_client.OpenApiResponse( ) _status_code_to_response = { '200': _response_for_200, + '202': _response_for_202, 'default': _response_for_default, } @@ -92,6 +120,7 @@ class BaseApi(api_client.Api): skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, ]: ... @@ -113,6 +142,7 @@ class BaseApi(api_client.Api): skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, api_client.ApiResponseWithoutDeserialization, ]: ... @@ -189,6 +219,7 @@ class DeleteCoffee(BaseApi): skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, ]: ... @@ -210,6 +241,7 @@ class DeleteCoffee(BaseApi): skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, api_client.ApiResponseWithoutDeserialization, ]: ... @@ -241,6 +273,7 @@ class ApiFordelete(BaseApi): skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, ]: ... @@ -262,6 +295,7 @@ class ApiFordelete(BaseApi): skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, api_client.ApiResponseWithoutDeserialization, ]: ... diff --git a/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.pyi b/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.pyi index c283abc29a9e..6602fe99aa61 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.pyi +++ b/samples/openapi3/client/petstore/python/petstore_api/paths/fake_delete_coffee_id/delete.pyi @@ -62,6 +62,28 @@ class ApiResponseFor200(api_client.ApiResponse): _response_for_200 = api_client.OpenApiResponse( response_cls=ApiResponseFor200, ) +XRateLimitSchema = schemas.DecimalSchema +ResponseHeadersFor202 = typing_extensions.TypedDict( + 'ResponseHeadersFor202', + { + 'X-Rate-Limit': XRateLimitSchema, + } +) + + +@dataclass +class ApiResponseFor202(api_client.ApiResponse): + response: urllib3.HTTPResponse + headers: ResponseHeadersFor202 + body: schemas.Unset = schemas.unset + + +_response_for_202 = api_client.OpenApiResponse( + response_cls=ApiResponseFor202, + headers=[ + x_rate_limit_parameter, + ] +) @dataclass @@ -86,6 +108,7 @@ class BaseApi(api_client.Api): skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, ]: ... @@ -107,6 +130,7 @@ class BaseApi(api_client.Api): skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, api_client.ApiResponseWithoutDeserialization, ]: ... @@ -183,6 +207,7 @@ class DeleteCoffee(BaseApi): skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, ]: ... @@ -204,6 +229,7 @@ class DeleteCoffee(BaseApi): skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, api_client.ApiResponseWithoutDeserialization, ]: ... @@ -235,6 +261,7 @@ class ApiFordelete(BaseApi): skip_deserialization: typing_extensions.Literal[False] = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, ]: ... @@ -256,6 +283,7 @@ class ApiFordelete(BaseApi): skip_deserialization: bool = ..., ) -> typing.Union[ ApiResponseFor200, + ApiResponseFor202, ApiResponseForDefault, api_client.ApiResponseWithoutDeserialization, ]: ...