quarkiverse / quarkus-openapi-generator

OpenAPI Generator - REST Client Generator
Apache License 2.0
108 stars 66 forks source link

Specified path in yaml gets URL encoded #664

Closed ennishol closed 4 months ago

ennishol commented 4 months ago

Hello, when an API specification defines path like this:

/?unused:

the generated client does not preserve the specified URL and encodes it to the path to /%3Funused The request log:

[org.apa.htt.imp.exe.MainClientExec] (executor-thread-1) Executing request POST /%3Funused HTTP/1.1
[org.apa.htt.headers] (executor-thread-1) http-outgoing-0 >> POST /%3Funused HTTP/1.1
[org.apa.htt.wire] (executor-thread-1) http-outgoing-0 >> "POST /%3Funused HTTP/1.1[\r][\n]"

Please change it to use the original spec without modifying or add some option to disable it for given API file or a path

To reproduce use tests in the attached demo

demo.tar.gz

Thank you very much!

mcruzdev commented 4 months ago

Hi @ennishol thank you for this issue!

If you want, open a pull request to solve this issue, what do you think?

ricardozanini commented 4 months ago

@ennishol, this is not an issue in this project. The path segment per RFC 3986, can't have the ? character, hence the engine is encoding it. So it's working as it's meant to be. See here a more detailed response: https://stackoverflow.com/a/4669755/1354502

In your case, the URI interpreter will see the first ? in the path and it will break it considering unused to be a querystring parameter with an empty var. So it will break your API anyway if we don't encode the ? char.

My suggestion: remove this path from your OpenAPI file or change it to unused. It smells a workaround anyway.

ennishol commented 4 months ago

@ricardozanini Thanks for looking into it. You are right, it is a problem with microprofile client and not the generator. Unfortunately, I am not in control of the API.

ricardozanini commented 4 months ago

@ennishol can't you just copy the OpenAPI yaml file, remove this path and go on?

ennishol commented 4 months ago

@ricardozanini Yes. that is what I'm doing. But I wrongly assumed it would be a problem with the open-api generator and wanted to report a bug/improvement. Sorry for bothering you

ricardozanini commented 4 months ago

No worries! We are happy to have you here and using our project 👍