Skip to content
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

Please add an example of @RequestBody #30

Open
bmarwell opened this issue Nov 20, 2018 · 6 comments
Open

Please add an example of @RequestBody #30

bmarwell opened this issue Nov 20, 2018 · 6 comments

Comments

@bmarwell
Copy link

bmarwell commented Nov 20, 2018

Hello OpenLiberty-Team!

Your example is a great way to learn about the OpenAPI spec. Please add an example about @RequestBody, that would be very helpful.

Reason: With OpenAPI 3.0, form-data parameters were moved from Parameter to RequestBody. So I initially thought that ParameterIn.RequestBody was missing. Instead, there is a requestBody annotation for those parameters, and the parameters need to be hidden.

See for reference: eclipse/microprofile-open-api#299

(Especially for a login which is using APPLICATION_FORM_URLENCODED).

@bmarwell
Copy link
Author

Just an additional question. I just tried the @RequestBody annotation, but in my method signature I got two Form Parameters, which are now set to "hidden". Still, the request body does not show up in the liberty generated openapi output. Do I need an additional parameter for the body? That would somehow be redundant to the existing parameters.

@yeekangc
Copy link
Member

@arturdzm @arthurdm, can you comment on the question above?

@arturdzm arturdzm self-assigned this Nov 20, 2018
@arturdzm
Copy link

Currently mpOpenAPI-1.0 does not support scanning of @FormParam annotation.
It is possible to use @RequestBody annotation as follows:

@Consumes(MediaType.APPLICATION_FORM_URLENCODED) @RequestBody(content=@Content(schema=@Schema(implementation=SomeModel.class)))

Using this approach it is possible to put parameter definitions into a POJO

@bmarwell
Copy link
Author

Thanks for your input.
The @RequestBody annotation can be applied to parameters, which is confusing. I added it to the String parameter, which (obviously) did not show up in the generated OpenAPI description. Is this a Liberty issue or a problem from the OpenAPI annotations?

@tt-le
Copy link
Contributor

tt-le commented Oct 28, 2020

Adding @RequestBody to parameters generated OpenAPI documentation for me. Can't seem to reproduce the issue in the latest version of OpenLiberty. It might have been fixed?

@bmarwell
Copy link
Author

Hi @tt-le,

thanks for your input. I can revise this issue (and create a minimal example) in a few weeks at best – sorry!

I can also add @RequestBody annotations to Parameters, but please also see my note that I am using multiple of those – @FormParam. Maybe that is the difference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants