File tree Expand file tree Collapse file tree 4 files changed +109
-2
lines changed
springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration
springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test
kotlin/test/org/springdoc/api/app12 Expand file tree Collapse file tree 4 files changed +109
-2
lines changed Original file line number Diff line number Diff line change @@ -92,9 +92,13 @@ class SpringDocKotlinConfiguration() {
9292 // parameter is not required if a default value is provided in @RequestParam
9393 else if (requestParam != null && requestParam.defaultValue != ValueConstants .DEFAULT_NONE )
9494 parameterModel.required = false
95- else
95+ else {
96+ val isJavaNullableAnnotationPresent = methodParameter.parameterAnnotations.any {
97+ it.annotationClass.qualifiedName == " jakarta.annotation.Nullable"
98+ }
9699 parameterModel.required =
97- kParameter.type.isMarkedNullable == false
100+ kParameter.type.isMarkedNullable == false && ! isJavaNullableAnnotationPresent
101+ }
98102 }
99103 }
100104 return @ParameterCustomizer parameterModel
Original file line number Diff line number Diff line change 1+ package test .org .springdoc .api .app12 ;
2+
3+ import jakarta .annotation .Nullable ;
4+ import test .org .springdoc .api .app12 .SpringDocApp12Test .MyEnum ;
5+
6+ import org .springframework .web .bind .annotation .GetMapping ;
7+ import org .springframework .web .bind .annotation .RestController ;
8+
9+ /**
10+ * @author bnasslahsen
11+ */
12+ @ RestController
13+ public class EnumController {
14+ @ GetMapping ("/test-enum-2" )
15+ String testEnum2 (@ Nullable MyEnum e ) {
16+ return "" ;
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ /*
2+ *
3+ * * Copyright 2019-2023 the original author or authors.
4+ * *
5+ * * Licensed under the Apache License, Version 2.0 (the "License");
6+ * * you may not use this file except in compliance with the License.
7+ * * You may obtain a copy of the License at
8+ * *
9+ * * https://www.apache.org/licenses/LICENSE-2.0
10+ * *
11+ * * Unless required by applicable law or agreed to in writing, software
12+ * * distributed under the License is distributed on an "AS IS" BASIS,
13+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * * See the License for the specific language governing permissions and
15+ * * limitations under the License.
16+ *
17+ */
18+
19+ package test.org.springdoc.api.app12
20+
21+ import org.springframework.boot.autoconfigure.SpringBootApplication
22+ import org.springframework.context.annotation.ComponentScan
23+ import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest
24+
25+ class SpringDocApp12Test : AbstractKotlinSpringDocMVCTest () {
26+
27+ @SpringBootApplication
28+ @ComponentScan(basePackages = [" org.springdoc" , " test.org.springdoc.api.app12" ])
29+ class DemoApplication
30+
31+ enum class MyEnum {
32+ A , B ;
33+ }
34+
35+ }
Original file line number Diff line number Diff line change 1+ {
2+ "openapi" : " 3.0.1" ,
3+ "info" : {
4+ "title" : " OpenAPI definition" ,
5+ "version" : " v0"
6+ },
7+ "servers" : [
8+ {
9+ "url" : " http://localhost" ,
10+ "description" : " Generated server url"
11+ }
12+ ],
13+ "paths" : {
14+ "/test-enum-2" : {
15+ "get" : {
16+ "tags" : [
17+ " enum-controller"
18+ ],
19+ "operationId" : " testEnum2" ,
20+ "parameters" : [
21+ {
22+ "name" : " e" ,
23+ "in" : " query" ,
24+ "required" : false ,
25+ "schema" : {
26+ "type" : " string" ,
27+ "enum" : [
28+ " A" ,
29+ " B"
30+ ]
31+ }
32+ }
33+ ],
34+ "responses" : {
35+ "200" : {
36+ "description" : " OK" ,
37+ "content" : {
38+ "*/*" : {
39+ "schema" : {
40+ "type" : " string"
41+ }
42+ }
43+ }
44+ }
45+ }
46+ }
47+ }
48+ },
49+ "components" : {}
50+ }
You can’t perform that action at this time.
0 commit comments