You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
note the @QueryParam annotations, which indicate these are parsed from the queryString, although the spec states these should be parsed from the request body.
which replaces the @FormParam annotation with @QueryParam.
Note that the commit is modifying formParams.mustache. That template should contain form parameters; query parameters are generated from queryParams.mustache
Suggest a fix
Replacing the @QueryParam with @FormParam resolves this issue.
Will create a PR with this fix.
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
The jersey3 generator creates
@QueryParam
annotations instead of@FormParam
annotations for form parametersopenapi-generator version
7.12.0
OpenAPI declaration file content or url
Note both
username
andpassword
fields are expected to be in the request body.( Full spec here: https://github.com/knoxg/openapi-generator-formparam-spec/blob/main/src/main/openapi/formparam-api.yaml )
Generation Details
Generate jersey3 stubs using the openapi-generator-maven-plugin, containing
I've created a project which generates the client stubs here: https://github.com/knoxg/openapi-generator-formparam-spec
Steps to reproduce
Run
mvn install
on the openapi-generator-formparam-spec projectThe generated com.randomnoun.example.api.CreateTokenApi.java contains:
note the
@QueryParam
annotations, which indicate these are parsed from the queryString, although the spec states these should be parsed from the request body.I've created another project which implements this interface here: https://github.com/knoxg/openapi-generator-formparam-impl
This dummy implementation just returns the supplied username and password fields; i.e.
( from https://github.com/knoxg/openapi-generator-formparam-impl/blob/main/src/main/java/com/randomnoun/example/api/impl/CreateTokenApiServiceImpl.java )
After building and running this webapp, the following curl request to this server
$ curl -s --show-error --fail-with-body -X POST \ -d "username=scott&password=tiger" \ http://localhost:8080/openapi-generator-formparam-impl/api/createToken
produces
which is incorrect.
However, this request
$ curl -s --show-error --fail-with-body -X POST \ 'http://localhost:8080/openapi-generator-formparam-impl/api/createToken?username=scott&password=tiger'
returns
indicating that the fields are incorrectly being consumed from the URL as queryString parameters.
We don't want these fields in the URL as they contain sensitive information.
Related issues/PRs
The jersey3 integration was implemented on PR #16335.
There is a comment on that PR ( #16335 (comment) ) which leads to this commit: adcb4fa
which replaces the
@FormParam
annotation with@QueryParam
.Note that the commit is modifying
formParams.mustache
. That template should contain form parameters; query parameters are generated fromqueryParams.mustache
Suggest a fix
Replacing the
@QueryParam
with@FormParam
resolves this issue.Will create a PR with this fix.
The text was updated successfully, but these errors were encountered: