Skip to content

Commit c14e206

Browse files
authored
Merge pull request #50916 from aureamunoz/allow-forcing-required-value-true
Allow forcing a RequestParam explicitly required
2 parents 846b21c + 1448ea6 commit c14e206

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

extensions/spring-web/resteasy-reactive/deployment/src/main/java/io/quarkus/spring/web/resteasy/reactive/deployment/SpringWebResteasyReactiveProcessor.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,6 @@ public void transform(TransformationContext transformationContext) {
303303
AnnotationValue defaultValue = annotation.value("defaultValue");
304304
if (defaultValue != null) {
305305
defaultValueStr = defaultValue.asString();
306-
} else {
307-
AnnotationValue requiredValue = annotation.value("required");
308-
if (requiredValue != null) {
309-
if (requiredValue.asBoolean()) {
310-
throw new IllegalArgumentException(
311-
"Using required @RequestMapping is not supported. Offending method is '"
312-
+ methodInfo.declaringClass().name() + "#" + methodInfo.name() + "'");
313-
}
314-
}
315306
}
316307
if (defaultValueStr != null) {
317308
transform.add(create(DEFAULT_VALUE, annotation.target(),

extensions/spring-web/resteasy-reactive/tests/src/test/java/io/quarkus/spring/web/requestparam/RequestParamController.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,19 @@ public String getFoosParamRequired(@RequestParam String id) {
8080
throw new IllegalStateException("Unexpected state. Should have not been called");
8181
}
8282

83+
@GetMapping("/api/foos/paramExplicitlyRequired")
84+
public String getFoosParamExplicitlyRequired(@RequestParam(required = true) String id) {
85+
throw new IllegalStateException("Unexpected state. Should have not been called");
86+
}
87+
8388
@RestControllerAdvice
8489
public static class RestExceptionHandler {
8590

8691
@ExceptionHandler(WebApplicationException.class)
8792
public ResponseEntity<Object> handleException(Exception ex) {
8893
return new ResponseEntity<>(ex.getMessage(), HttpStatus.BAD_REQUEST);
8994
}
95+
9096
}
9197

9298
}

extensions/spring-web/resteasy-reactive/tests/src/test/java/io/quarkus/spring/web/requestparam/RequestParamControllerTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ public void shouldFailWithBadRequestWhenMissingMandatoryParam() throws Exception
129129
when().get("/api/foos/paramRequired")
130130
.then()
131131
.statusCode(400).body(containsString("Missing required param in method"));
132+
133+
when().get("/api/foos/paramExplicitlyRequired")
134+
.then()
135+
.statusCode(400).body(containsString("Missing required param in method"));
132136
}
133137

134138
}

0 commit comments

Comments
 (0)