Skip to content

Commit 1155890

Browse files
committed
Changes report for #3064
1 parent 9545c31 commit 1155890

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocKotlinConfiguration.kt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,6 @@ class SpringDocKotlinConfiguration() {
6969
.addDeprecatedType(Deprecated::class.java)
7070
}
7171

72-
@Bean
73-
@ConditionalOnProperty(
74-
name = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED],
75-
matchIfMissing = true
76-
)
77-
@Lazy(false)
78-
fun kotlinDefaultsInParamObjects(): DelegatingMethodParameterCustomizer =
79-
DelegatingMethodParameterCustomizer { _, mp ->
80-
val kProp = mp.containingClass.kotlin.primaryConstructor
81-
?.parameters
82-
?.firstOrNull { it.name == mp.parameterName }
83-
if (kProp?.isOptional == true)
84-
(mp as DelegatingMethodParameter).isNotRequired = true
85-
}
8672

8773
@ConditionalOnClass(name = ["kotlin.reflect.full.KClasses"])
8874
class KotlinReflectDependingConfiguration {
@@ -100,6 +86,21 @@ class SpringDocKotlinConfiguration() {
10086
fun kotlinModelConverter(objectMapperProvider: ObjectMapperProvider): KotlinInlineClassUnwrappingConverter {
10187
return KotlinInlineClassUnwrappingConverter(objectMapperProvider)
10288
}
89+
90+
@Bean
91+
@ConditionalOnProperty(
92+
name = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED],
93+
matchIfMissing = true
94+
)
95+
@Lazy(false)
96+
fun kotlinDefaultsInParamObjects(): DelegatingMethodParameterCustomizer =
97+
DelegatingMethodParameterCustomizer { _, mp ->
98+
val kProp = mp.containingClass.kotlin.primaryConstructor
99+
?.parameters
100+
?.firstOrNull { it.name == mp.parameterName }
101+
if (kProp?.isOptional == true)
102+
(mp as DelegatingMethodParameter).isNotRequired = true
103+
}
103104
}
104105

105106
}

0 commit comments

Comments
 (0)