question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make request body required by default

See original GitHub issue

As 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:open
  • Created 4 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
EricWittmanncommented, Jun 17, 2019

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 to true. 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:

  • Change the default value of this to true
  • Update the javadoc to explain why it’s true when most other boolean property defaults are false
  • Update the text of the specification to better explain default annotation properties more broadly
  • Maintain a table of exceptions (like this one) where appropriate
  • Add a TCK test to ensure that implementations properly handle this case
0reactions
MikeEdgarcommented, Feb 28, 2022

Placing this in the 4.0 milestone as it requires implementations to generate required: true for request bodies which is a change in behaviour.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found