Description
The python generator does not send the body in POST requests that require data encoded as application/x-www-form-urlencoded. Also, data serialized for application/x-www-form-urlencoded should not be prefixed with a question mark '?'.
openapi-generator version
6.2.1-SNAPSHOT (built from master)
OpenAPI declaration file content or url
The petstore.yaml specification used for tests in this repo can be used to reproduce this issue.
Generation Details
The normal tests in this repo can reproduce this issue:
./bin/generate-samples.sh ./bin/configs/python*
Steps to reproduce
I found this issue when using the /v5/oauth/token endpoint documented in https://github.com/pinterest/api-description but I'm pretty sure that doing a POST to the petstore /pet/{petId} endpoint using a client generated for python would also reproduce this bug.
Related issues/PRs
I don't understand issue #2411 completely, but it might be fixed when this issue is fixed.
Suggest a fix
I'll submit a pull request with this patch...
$ git diff modules
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 bdcd4519ff4..13f4e01ee51 100644
--- a/modules/openapi-generator/src/main/resources/python/api_client.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/api_client.handlebars
@@ -293,7 +293,7 @@ class StyleFormSerializer(ParameterSerializerBase):
prefix_separator_iterator: typing.Optional[PrefixSeparatorIterator] = None
) -> str:
if prefix_separator_iterator is None:
- prefix_separator_iterator = PrefixSeparatorIterator('?', '&')
+ prefix_separator_iterator = PrefixSeparatorIterator('', '&')
return self._ref6570_expansion(
variable_name=name,
in_data=in_data,
diff --git a/modules/openapi-generator/src/main/resources/python/rest.handlebars b/modules/openapi-generator/src/main/resources/python/rest.handlebars
index b1811396168..2ca16e1639e 100644
--- a/modules/openapi-generator/src/main/resources/python/rest.handlebars
+++ b/modules/openapi-generator/src/main/resources/python/rest.handlebars
@@ -139,6 +139,7 @@ class RESTClientObject(object):
elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501
r = self.pool_manager.request(
method, url,
+ body=body,
fields=fields,
encode_multipart=False,
preload_content=not stream,
Copied from OpenAPITools/openapi-generator#13722
Description
The python generator does not send the body in POST requests that require data encoded as application/x-www-form-urlencoded. Also, data serialized for application/x-www-form-urlencoded should not be prefixed with a question mark '?'.
openapi-generator version
6.2.1-SNAPSHOT (built from master)
OpenAPI declaration file content or url
The petstore.yaml specification used for tests in this repo can be used to reproduce this issue.
Generation Details
The normal tests in this repo can reproduce this issue:
Steps to reproduce
I found this issue when using the /v5/oauth/token endpoint documented in https://github.com/pinterest/api-description but I'm pretty sure that doing a POST to the petstore /pet/{petId} endpoint using a client generated for python would also reproduce this bug.
Related issues/PRs
I don't understand issue #2411 completely, but it might be fixed when this issue is fixed.
Suggest a fix
I'll submit a pull request with this patch...
Copied from OpenAPITools/openapi-generator#13722