Skip to content

Commit 4fd4344

Browse files
committed
modify test for springdoc.trim-kotlin-indent
1 parent 71a0684 commit 4fd4344

File tree

2 files changed

+148
-6
lines changed
  • springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test

2 files changed

+148
-6
lines changed

springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/ExampleController.kt

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package test.org.springdoc.api.app11
22

33
import io.swagger.v3.oas.annotations.Operation
4+
import io.swagger.v3.oas.annotations.media.Schema
45
import org.springframework.web.bind.annotation.GetMapping
6+
import org.springframework.web.bind.annotation.RequestBody
57
import org.springframework.web.bind.annotation.RequestParam
68
import org.springframework.web.bind.annotation.RestController
79

@@ -20,11 +22,75 @@ class ExampleController {
2022
| 400 | STORE_NOT_FOUND |Store not found. | | |
2123
"""
2224
)
23-
@GetMapping("/foo/remove-kotlin-indent")
25+
@GetMapping("/foo/trim-kotlin-indent")
2426
fun readFoo(@RequestParam name: String?) = FooResponse("Hello ${name ?: "world"}")
2527

2628
}
2729

2830
data class FooResponse(
29-
private val name: String,
30-
)
31+
val name: String,
32+
)
33+
34+
@RestController
35+
class ExampleController2 {
36+
37+
@GetMapping("/foo/trim-kotlin-indent/schema")
38+
fun readFoo(
39+
@RequestBody request: FooRequestWithSchema,
40+
) = FooResponseWithSchema(
41+
name = "Hello ${request.age ?: "world"}",
42+
subFoo = SubFooResponseWithSchema(subName = "sub foo name"),
43+
)
44+
}
45+
46+
@Schema(
47+
name = "foo request",
48+
description = """
49+
foo request class description
50+
with kotlin indent
51+
"""
52+
)
53+
data class FooRequestWithSchema(
54+
@Schema(
55+
name = "age",
56+
description = """
57+
foo request field with kotlin indent
58+
"""
59+
)
60+
val age: Int,
61+
)
62+
63+
@Schema(
64+
name = "foo response",
65+
description = """
66+
foo response class description
67+
with kotlin indent
68+
"""
69+
)
70+
data class FooResponseWithSchema(
71+
@Schema(
72+
name = "name",
73+
description = """
74+
foo response fields with kotlin indent
75+
"""
76+
)
77+
val name: String,
78+
val subFoo: SubFooResponseWithSchema
79+
)
80+
81+
@Schema(
82+
name = "sub foo response",
83+
description = """
84+
sub foo response class description
85+
with kotlin indent
86+
"""
87+
)
88+
data class SubFooResponseWithSchema(
89+
@Schema(
90+
name = "subName",
91+
description = """
92+
sub foo response fields with kotlin indent
93+
"""
94+
)
95+
val subName: String,
96+
)

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

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"paths": {
14-
"/foo/remove-kotlin-indent": {
14+
"/foo/trim-kotlin-indent": {
1515
"get": {
1616
"tags": [
1717
"example-controller"
@@ -42,18 +42,94 @@
4242
}
4343
}
4444
}
45+
},
46+
"/foo/trim-kotlin-indent/schema": {
47+
"get": {
48+
"tags": [
49+
"example-controller-2"
50+
],
51+
"operationId": "readFoo_1",
52+
"parameters": [
53+
{
54+
"name": "request",
55+
"in": "query",
56+
"required": true,
57+
"schema": {
58+
"$ref": "#/components/schemas/foo request"
59+
}
60+
}
61+
],
62+
"responses": {
63+
"200": {
64+
"description": "OK",
65+
"content": {
66+
"*/*": {
67+
"schema": {
68+
"$ref": "#/components/schemas/foo response"
69+
}
70+
}
71+
}
72+
}
73+
}
74+
}
4575
}
4676
},
4777
"components": {
4878
"schemas": {
4979
"FooResponse": {
80+
"required": [
81+
"name"
82+
],
5083
"type": "object",
5184
"properties": {
5285
"name": {
53-
"type": "string",
54-
"writeOnly": true
86+
"type": "string"
5587
}
5688
}
89+
},
90+
"foo request": {
91+
"required": [
92+
"age"
93+
],
94+
"type": "object",
95+
"properties": {
96+
"age": {
97+
"type": "integer",
98+
"description": "\nfoo request field with kotlin indent\n",
99+
"format": "int32"
100+
}
101+
},
102+
"description": "\nfoo request class description\nwith kotlin indent\n"
103+
},
104+
"foo response": {
105+
"required": [
106+
"name",
107+
"subFoo"
108+
],
109+
"type": "object",
110+
"properties": {
111+
"name": {
112+
"type": "string",
113+
"description": "\nfoo response fields with kotlin indent\n"
114+
},
115+
"subFoo": {
116+
"$ref": "#/components/schemas/sub foo response"
117+
}
118+
},
119+
"description": "\nfoo response class description\nwith kotlin indent\n"
120+
},
121+
"sub foo response": {
122+
"required": [
123+
"subName"
124+
],
125+
"type": "object",
126+
"properties": {
127+
"subName": {
128+
"type": "string",
129+
"description": "\nsub foo response fields with kotlin indent\n"
130+
}
131+
},
132+
"description": "\nsub foo response class description\nwith kotlin indent\n"
57133
}
58134
}
59135
}

0 commit comments

Comments
 (0)