Make request body required by default
See original GitHub issueAs per @EricWittmann’s request following a discussion in https://github.com/smallrye/smallrye-open-api/issues/110#issuecomment-493473681 I propose to make the required
property of @RequestBody
true by default
because more often than not you expect the request body and depend on it
For reference, this is the current state: https://github.com/eclipse/microprofile-open-api/blob/49e31ea4bf6da48f8491327e1df7f4e47febfc3a/api/src/main/java/org/eclipse/microprofile/openapi/annotations/parameters/RequestBody.java#L59
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Use @RequestBody with optional body in latest Spring v4
Whether body content is required. Default is true, leading to an exception thrown in case there is no body content. Switch this to...
Read more >Describing Request Body - Swagger
requestBody consists of the content object, an optional Markdown-formatted description , and an optional required flag ( false by default). content lists ...
Read more >RequestBody (Spring Framework 6.0.3 API)
Whether body content is required. Default is true , leading to an exception thrown in case there is no body content. Switch this...
Read more >Spring's RequestBody and ResponseBody Annotations
By default, the type we annotate with the @RequestBody annotation must correspond to the JSON sent from our client-side controller:.
Read more >The @RequestBody Annotation - Spring Framework Guru
When the HTTP clients send data with the request, the data is in the request body. On the application side, you need a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After further discussion in today’s bi-weekly specification meeting, we have reached a consensus that we will, in fact, change the default value of the
reqired
property totrue
. This does make sense in the framework of default values of annotations, but it represents an exception relative to other annotation property default values. An explanation of what I mean by that can be found here:https://github.com/eclipse/microprofile-open-api/issues/356#issuecomment-502763082
The tldr is that we’ll make the following changes:
true
false
Placing this in the 4.0 milestone as it requires implementations to generate
required: true
for request bodies which is a change in behaviour.