openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] [python-legacy] No return value if only 'default' response type specified

Open felixvd opened this issue 3 years ago • 1 comments

Bug Report Checklist

  • [X] Have you provided a full/minimal spec to reproduce the issue? --> petstore_oas3_test.yaml should produce the problem
  • [X] Have you validated the input using an OpenAPI validator (example)?
  • [X] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [X] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)

Summary: For endpoints that only specify a default response, python-legacy clients always return None.

Description

If only the default response exists for an endpoint in the schema, that endpoint will pass an empty response_types_map to call_api:

        response_types_map = {}

This is fatal, because it causes the response not to be serialized in __call_api of api_client.py, so each call will return None.

Endpoints where the responses field contains the number codes '200' work:

        response_types_map = {
            200: "list[Pet]",
            400: None,
        }
openapi-generator version

5.4.0

OpenAPI declaration file content or url

https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/test/resources/3_0/petstore_oas3_test.yaml

Generation Details

openapi-generator-cli generate -i petstore_oas3_test.yaml -g python-legacy has both non-working and working endpoints

Steps to reproduce
cd $YOUR_OPENAPI_GENERATOR_REPO
mkdir openapi-legacy-bugged-client && cd openapi-legacy-bugged-client
openapi-generator-cli generate -i ../modules/openapi-generator/src/test/resources/3_0/petstore_oas3_test.yaml -g python-legacy

Open api/pet_api.py with your favorite editor and search for response_types_map = { to see the issue.

Suggest a fix

I don't know yet, but the python generator does not have this problem, so the solution can surely be found in that template. If you know where to look I am thankful for pointers.

felixvd avatar Mar 04 '22 07:03 felixvd

I stumbled here because I have exactly the same problem, in my endpoints I only have a default response and I get

response_types_map = {}

I'm using python generator with openapi-generator-cli 7.5.0

Is there a workaround ?

resposit avatar May 15 '24 16:05 resposit

Same here, using openapi-generator-cli 7.7.0 and the python generator (not python-legacy)

tgrtb avatar Jul 10 '24 10:07 tgrtb