guide-microprofile-openapi
guide-microprofile-openapi copied to clipboard
Please add an example of @RequestBody
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: https://github.com/eclipse/microprofile-open-api/issues/299
(Especially for a login which is using APPLICATION_FORM_URLENCODED).
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.
@arturdzm @arthurdm, can you comment on the question above?
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
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?
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?
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?