Skip to content

Commit 0cf0153

Browse files
committed
Regression in generating doc for Kotlin LinkedHashSet. Fixes #3178
1 parent 0679f91 commit 0cf0153

3 files changed

Lines changed: 52 additions & 4 deletions

File tree

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/KotlinDeprecatedPropertyCustomizer.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ class KotlinDeprecatedPropertyCustomizer(
5656

5757
val javaType: JavaType =
5858
objectMapperProvider.jsonMapper().constructType(type.type)
59+
if (javaType.rawClass.packageName.startsWith("java.")) {
60+
return resolvedSchema
61+
}
62+
5963
val kotlinClass = javaType.rawClass.kotlin
6064

6165
// Check each property of the class

springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
package test.org.springdoc.api.v31.app3
2020

21+
import org.springframework.boot.runApplication
2122
import org.springframework.web.bind.annotation.GetMapping
2223
import org.springframework.web.bind.annotation.RequestMapping
2324
import org.springframework.web.bind.annotation.RestController
25+
import test.org.springdoc.api.v31.app22.DemoApp
2426

2527
enum class SystemStatus(val status: String) {
2628
OK("OK")
@@ -30,9 +32,17 @@ data class SystemStatusResponse(
3032
val status: SystemStatus
3133
)
3234

35+
data class Foo(
36+
val bar: LinkedHashSet<String>,
37+
)
38+
3339
@RestController
3440
@RequestMapping("/status")
3541
class SystemStatusController {
42+
43+
@GetMapping("/bar")
44+
fun getTestData(): Foo = Foo(bar = linkedSetOf("test"))
45+
3646
@GetMapping
3747
fun index() = SystemStatusResponse(SystemStatus.OK)
3848

springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app3.json

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,31 @@
5151
},
5252
"deprecated": true
5353
}
54+
},
55+
"/status/bar": {
56+
"get": {
57+
"tags": [
58+
"system-status-controller"
59+
],
60+
"operationId": "getTestData",
61+
"responses": {
62+
"200": {
63+
"description": "OK",
64+
"content": {
65+
"*/*": {
66+
"schema": {
67+
"$ref": "#/components/schemas/Foo"
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}
5474
}
5575
},
5676
"components": {
5777
"schemas": {
5878
"SystemStatusResponse": {
59-
"required": [
60-
"status"
61-
],
6279
"type": "object",
6380
"properties": {
6481
"status": {
@@ -67,7 +84,24 @@
6784
"OK"
6885
]
6986
}
70-
}
87+
},
88+
"required": [
89+
"status"
90+
]
91+
},
92+
"Foo": {
93+
"type": "object",
94+
"properties": {
95+
"bar": {
96+
"type": "array",
97+
"items": {
98+
"type": "string"
99+
}
100+
}
101+
},
102+
"required": [
103+
"bar"
104+
]
71105
}
72106
}
73107
}

0 commit comments

Comments
 (0)