Closed
Description
Describe the bug
Using @RequestParam(required = false) does not work since v2.0.3. It will always show the field as required in the specifications.
To Reproduce
Steps to reproduce the behavior:
- What version of spring-boot you are using?
3.0.4 - What modules and versions of springdoc-openapi are you using?
2.0.4 - Provide with a sample code (HelloController) or Test that reproduces the problem
java
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "Test")
@RestController
@RequestMapping(value = "/api/v2/test", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public class TestController {
@GetMapping
public ResponseEntity<Void> getTest(
@RequestParam(defaultValue = "false", required = false) boolean includeClosed) {
return ResponseEntity.noContent().build();
}
}
Expected behavior
Expect the swagger docs to say the field is not required.
Screenshots
V2.0.4
V2.0.2
No code has been changed between both pictures. Only the version.
Additional context
Using Java 17