-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with response_type on Python client #10129
Comments
Happens for me too. This is the proximate cause of the bug: swagger-codegen/modules/swagger-codegen/src/main/resources/python/api_client.mustache Lines 272 to 276 in 74393ff
I was able to fix it the same way Juan mentioned, treating "Object" as "object". # convert str to class
if klass in self.NATIVE_TYPES_MAPPING:
klass = self.NATIVE_TYPES_MAPPING[klass]
elif hasattr(arturo_client.models, klass):
klass = getattr(arturo_client.models, klass)
elif klass == "Object":
klass = self.NATIVE_TYPES_MAPPING["object"] I'm not sure if this special case is the right fix or if it's part of a bigger bug, though. |
working with 3.0.25 and still getting this error
did this in generated code, not sure where it needs to be in this repo |
edit: PythonClientCodegen gets a null in toModelName and returns "Object" instead of "object". I'm making a PR for this fix. |
The above commit should resolve this. |
Generating Python client with codegen, the code has an error in the default_api.py file.
In runtime I'm sending data with a client function, the error that I get is:
manually checking the code the error is in api_client.py/__deserialize function:
The error raise in the last line of the code shared above, the 'klass' variable value is "Object" (with uppercase O). I think that the root of the problem is on:
response_type
is where the klass variable is being settled.This is part of a function generated based on an API endpoint, the function name is:
the endpoint function in the original python client is
add_patient
.I change the reponse_type manually to test if the error is actually there, and if I change it for "object" or for a valid model class name, it works like a charm.
I was looking how this response_type is being generated in order to make any necessary change in the openapi.json used to generate this, but I didn't found the proper value to set on openapi.
From my point of view, this could be a bug in codegen, but maybe is something wrong with my openapi.json, if someone can guide me to make the changes on the openapi, it would be nice, but if this is a bug on codegen, I can't do more than wait
swagger-cogen version: 3.0.18
Command line used for generation
On linux:
java -jar swagger-codegen-cli.jar generate -i http://localhost:8000/openapi.json -l python -c swagger-config-inbound-manager-client.json
On mac:
swagger-codegen generate -i http://127.0.0.1:8000/openapi.json -l python -c swagger-config-inbound-manager-client.json
(same problem with both versions)
Openapi.json file link
https://gist.github.com/juanpaps03/21fac4119749f6668dd5f7797cbb4c08
The text was updated successfully, but these errors were encountered: