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

Fix python-fastapi signature of parameters for method

Open diorcety opened this issue 1 year ago • 2 comments

If the parameter type is an map or a list an invalid python was producted, for example:

body: = Body(None, description=""),

This PR use function postProcessOperationsWithModels of AbstracPythonCodegen in order to use vendorExtensions.x-py-typing

diorcety avatar May 16 '24 17:05 diorcety

@diorcety do you have a test that you could add to show the problem and how your change fixes it?

multani avatar May 20 '24 16:05 multani

An integrated test? no for the moment, but a json file yes, the one from grafana: https://github.com/grafana/grafana/blob/main/public/openapi3.json

diorcety avatar May 22 '24 10:05 diorcety

@diorcety can you please update the test spec modules/openapi-generator/src/test/resources/3_0/python-fastapi/petstore.yaml with a test or 2 and update the samples so that the CI can verify the change?

wing328 avatar May 26 '24 08:05 wing328

@diorcety can you please update the test spec modules/openapi-generator/src/test/resources/3_0/python-fastapi/petstore.yaml with a test or 2 and update the samples so that the CI can verify the change?

Done. The example comes from grafana API. The issue is really related to "lazy" body definition which is solved by using the same function that client generator

diorcety avatar Jun 03 '24 13:06 diorcety

I've filed https://github.com/OpenAPITools/openapi-generator/pull/19830 and limited the change only to python fastapi (as python client generators do not use the responses at the moment)

wing328 avatar Oct 10 '24 07:10 wing328

closed via https://github.com/OpenAPITools/openapi-generator/pull/19830

thanks for the contribution

wing328 avatar Oct 10 '24 07:10 wing328