Skip to content

Commit ebd3f65

Browse files
committed
Add tests for @ParameterObject on spring boot webflux. Fixes #1325
1 parent dd0a8eb commit ebd3f65

File tree

5 files changed

+312
-0
lines changed

5 files changed

+312
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package test.org.springdoc.api.app102;
2+
3+
import javax.validation.constraints.NotBlank;
4+
5+
import io.swagger.v3.oas.annotations.Parameter;
6+
7+
public class InheritedRequestParams extends RequestParams {
8+
@Parameter(description = "parameter from child of RequestParams")
9+
@NotBlank
10+
private String childParam;
11+
12+
public String getChildParam() {
13+
return childParam;
14+
}
15+
16+
public void setChildParam(String childParam) {
17+
this.childParam = childParam;
18+
}
19+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package test.org.springdoc.api.app102;
2+
3+
import java.math.BigInteger;
4+
import java.util.List;
5+
import java.util.Optional;
6+
7+
import io.swagger.v3.oas.annotations.Parameter;
8+
9+
import org.springframework.lang.Nullable;
10+
11+
public class RequestParams {
12+
13+
@Parameter(description = "string parameter")
14+
private String stringParam;
15+
16+
@Deprecated
17+
private String stringParam1;
18+
19+
@Parameter(description = "string parameter2", required = true)
20+
private String stringParam2;
21+
22+
@Parameter(description = "int parameter")
23+
private int intParam;
24+
25+
private Optional<String> intParam2;
26+
27+
@Nullable
28+
private String intParam3;
29+
30+
private Nested nested;
31+
32+
private List<Nested> nestedList;
33+
34+
public String getStringParam() {
35+
return stringParam;
36+
}
37+
38+
public void setStringParam(String stringParam) {
39+
this.stringParam = stringParam;
40+
}
41+
42+
public int getIntParam() {
43+
return intParam;
44+
}
45+
46+
public void setIntParam(int intParam) {
47+
this.intParam = intParam;
48+
}
49+
50+
public Optional<String> getIntParam2() {
51+
return intParam2;
52+
}
53+
54+
public void setIntParam2(Optional<String> intParam2) {
55+
this.intParam2 = intParam2;
56+
}
57+
58+
@Nullable
59+
public String getIntParam3() {
60+
return intParam3;
61+
}
62+
63+
public void setIntParam3(@Nullable String intParam3) {
64+
this.intParam3 = intParam3;
65+
}
66+
67+
public String getStringParam1() {
68+
return stringParam1;
69+
}
70+
71+
public void setStringParam1(String stringParam1) {
72+
this.stringParam1 = stringParam1;
73+
}
74+
75+
public String getStringParam2() {
76+
return stringParam2;
77+
}
78+
79+
public void setStringParam2(String stringParam2) {
80+
this.stringParam2 = stringParam2;
81+
}
82+
83+
public Nested getNested() {
84+
return nested;
85+
}
86+
87+
public void setNested(Nested nested) {
88+
this.nested = nested;
89+
}
90+
91+
public List<Nested> getNestedList() {
92+
return nestedList;
93+
}
94+
95+
public void setNestedList(List<Nested> nestedList) {
96+
this.nestedList = nestedList;
97+
}
98+
99+
public static class Nested {
100+
private String param1;
101+
102+
private BigInteger param2;
103+
104+
@Parameter(description = "nested string parameter")
105+
public String getParam1() {
106+
return param1;
107+
}
108+
109+
public void setParam1(String param1) {
110+
this.param1 = param1;
111+
}
112+
113+
@Parameter(description = "nested BigInteger parameter")
114+
public BigInteger getParam2() {
115+
return param2;
116+
}
117+
118+
public void setParam2(BigInteger param2) {
119+
this.param2 = param2;
120+
}
121+
}
122+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package test.org.springdoc.api.app102;
2+
3+
import test.org.springdoc.api.AbstractSpringDocTest;
4+
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.context.annotation.ComponentScan;
7+
8+
public class SpringDocApp102Test extends AbstractSpringDocTest {
9+
10+
@SpringBootApplication
11+
@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app102" })
12+
static class SpringDocTestApp {}
13+
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package test.org.springdoc.api.app102;
2+
3+
import org.springdoc.api.annotations.ParameterObject;
4+
5+
import org.springframework.lang.Nullable;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
import org.springframework.web.bind.annotation.RequestParam;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
@RestController
11+
public class TestController {
12+
@GetMapping("test")
13+
public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) {
14+
}
15+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"paths": {
14+
"/test": {
15+
"get": {
16+
"tags": [
17+
"test-controller"
18+
],
19+
"operationId": "getTest",
20+
"parameters": [
21+
{
22+
"name": "param",
23+
"in": "query",
24+
"required": false,
25+
"schema": {
26+
"type": "string"
27+
}
28+
},
29+
{
30+
"name": "childParam",
31+
"in": "query",
32+
"description": "parameter from child of RequestParams",
33+
"required": true,
34+
"schema": {
35+
"type": "string"
36+
}
37+
},
38+
{
39+
"name": "stringParam",
40+
"in": "query",
41+
"description": "string parameter",
42+
"required": false,
43+
"schema": {
44+
"type": "string"
45+
}
46+
},
47+
{
48+
"name": "stringParam1",
49+
"in": "query",
50+
"required": false,
51+
"deprecated": true,
52+
"schema": {
53+
"type": "string"
54+
}
55+
},
56+
{
57+
"name": "stringParam2",
58+
"in": "query",
59+
"description": "string parameter2",
60+
"required": true,
61+
"schema": {
62+
"type": "string"
63+
}
64+
},
65+
{
66+
"name": "intParam",
67+
"in": "query",
68+
"description": "int parameter",
69+
"required": false,
70+
"schema": {
71+
"type": "integer",
72+
"format": "int32"
73+
}
74+
},
75+
{
76+
"name": "intParam2",
77+
"in": "query",
78+
"required": false,
79+
"schema": {
80+
"type": "string"
81+
}
82+
},
83+
{
84+
"name": "intParam3",
85+
"in": "query",
86+
"required": false,
87+
"schema": {
88+
"type": "string"
89+
}
90+
},
91+
{
92+
"name": "nested.param1",
93+
"in": "query",
94+
"required": false,
95+
"schema": {
96+
"type": "string"
97+
}
98+
},
99+
{
100+
"name": "nested.param2",
101+
"in": "query",
102+
"required": false,
103+
"schema": {
104+
"type": "integer"
105+
}
106+
},
107+
{
108+
"name": "nestedList",
109+
"in": "query",
110+
"required": false,
111+
"schema": {
112+
"type": "array",
113+
"items": {
114+
"$ref": "#/components/schemas/Nested"
115+
}
116+
}
117+
}
118+
],
119+
"responses": {
120+
"200": {
121+
"description": "OK"
122+
}
123+
}
124+
}
125+
}
126+
},
127+
"components": {
128+
"schemas": {
129+
"Nested": {
130+
"type": "object",
131+
"properties": {
132+
"param1": {
133+
"type": "string"
134+
},
135+
"param2": {
136+
"type": "integer"
137+
}
138+
}
139+
}
140+
}
141+
}
142+
}

0 commit comments

Comments
 (0)