Skip to content

Commit 8eb3064

Browse files
authored
[Java][Spring] Change methodBody.mustache for webflux bean validation (#13795)
1 parent 3d57816 commit 8eb3064

File tree

15 files changed

+184
-37
lines changed

15 files changed

+184
-37
lines changed

modules/openapi-generator/src/main/resources/JavaSpring/methodBody.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ Mono<Void> result = Mono.empty();
4343
{{^examples}}
4444
exchange.getResponse().setStatusCode({{#returnSuccessCode}}HttpStatus.OK{{/returnSuccessCode}}{{^returnSuccessCode}}HttpStatus.NOT_IMPLEMENTED{{/returnSuccessCode}});
4545
{{/examples}}
46-
return result.then(Mono.empty());
46+
return result{{#allParams}}{{#isBodyParam}}{{^isArray}}{{#paramName}}.then({{.}}){{/paramName}}{{/isArray}}{{#isArray}}{{#paramName}}.thenMany({{.}}){{/paramName}}{{/isArray}}{{/isBodyParam}}{{/allParams}}.then(Mono.empty());
4747
{{/reactive}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* OpenAPI Petstore
3+
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package org.openapitools.client.model;
15+
16+
import com.google.gson.TypeAdapter;
17+
import com.google.gson.annotations.JsonAdapter;
18+
import com.google.gson.annotations.SerializedName;
19+
import com.google.gson.stream.JsonReader;
20+
import com.google.gson.stream.JsonWriter;
21+
import io.swagger.annotations.ApiModel;
22+
import io.swagger.annotations.ApiModelProperty;
23+
import java.io.IOException;
24+
import java.math.BigDecimal;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
import org.junit.jupiter.api.Disabled;
28+
import org.junit.jupiter.api.Test;
29+
30+
31+
/**
32+
* Model tests for ArrayOfArrayOfNumberOnly
33+
*/
34+
public class ArrayOfArrayOfNumberOnlyTest {
35+
private final ArrayOfArrayOfNumberOnly model = new ArrayOfArrayOfNumberOnly();
36+
37+
/**
38+
* Model tests for ArrayOfArrayOfNumberOnly
39+
*/
40+
@Test
41+
public void testArrayOfArrayOfNumberOnly() {
42+
// TODO: test ArrayOfArrayOfNumberOnly
43+
}
44+
45+
/**
46+
* Test the property 'arrayArrayNumber'
47+
*/
48+
@Test
49+
public void arrayArrayNumberTest() {
50+
// TODO: test arrayArrayNumber
51+
}
52+
53+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* OpenAPI Petstore
3+
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package org.openapitools.client.model;
15+
16+
import com.google.gson.TypeAdapter;
17+
import com.google.gson.annotations.JsonAdapter;
18+
import com.google.gson.annotations.SerializedName;
19+
import com.google.gson.stream.JsonReader;
20+
import com.google.gson.stream.JsonWriter;
21+
import io.swagger.annotations.ApiModel;
22+
import io.swagger.annotations.ApiModelProperty;
23+
import java.io.IOException;
24+
import java.util.ArrayList;
25+
import java.util.List;
26+
import org.openapitools.client.model.Category;
27+
import org.openapitools.client.model.Tag;
28+
import org.junit.jupiter.api.Disabled;
29+
import org.junit.jupiter.api.Test;
30+
31+
32+
/**
33+
* Model tests for Pet
34+
*/
35+
public class PetTest {
36+
private final Pet model = new Pet();
37+
38+
/**
39+
* Model tests for Pet
40+
*/
41+
@Test
42+
public void testPet() {
43+
// TODO: test Pet
44+
}
45+
46+
/**
47+
* Test the property 'id'
48+
*/
49+
@Test
50+
public void idTest() {
51+
// TODO: test id
52+
}
53+
54+
/**
55+
* Test the property 'category'
56+
*/
57+
@Test
58+
public void categoryTest() {
59+
// TODO: test category
60+
}
61+
62+
/**
63+
* Test the property 'name'
64+
*/
65+
@Test
66+
public void nameTest() {
67+
// TODO: test name
68+
}
69+
70+
/**
71+
* Test the property 'photoUrls'
72+
*/
73+
@Test
74+
public void photoUrlsTest() {
75+
// TODO: test photoUrls
76+
}
77+
78+
/**
79+
* Test the property 'tags'
80+
*/
81+
@Test
82+
public void tagsTest() {
83+
// TODO: test tags
84+
}
85+
86+
/**
87+
* Test the property 'status'
88+
*/
89+
@Test
90+
public void statusTest() {
91+
// TODO: test status
92+
}
93+
94+
}

samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ default Mono<ResponseEntity<Client>> call123testSpecialTags(Mono<Client> body,
4646
break;
4747
}
4848
}
49-
return result.then(Mono.empty());
49+
return result.then(body).then(Mono.empty());
5050

5151
}
5252

samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeApiDelegate.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ default Mono<ResponseEntity<Void>> createXmlItem(Mono<XmlItem> xmlItem,
4949
ServerWebExchange exchange) {
5050
Mono<Void> result = Mono.empty();
5151
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
52-
return result.then(Mono.empty());
52+
return result.then(xmlItem).then(Mono.empty());
5353

5454
}
5555

@@ -65,7 +65,7 @@ default Mono<ResponseEntity<Boolean>> fakeOuterBooleanSerialize(Mono<Boolean> bo
6565
ServerWebExchange exchange) {
6666
Mono<Void> result = Mono.empty();
6767
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
68-
return result.then(Mono.empty());
68+
return result.then(body).then(Mono.empty());
6969

7070
}
7171

@@ -88,7 +88,7 @@ default Mono<ResponseEntity<OuterComposite>> fakeOuterCompositeSerialize(Mono<Ou
8888
break;
8989
}
9090
}
91-
return result.then(Mono.empty());
91+
return result.then(body).then(Mono.empty());
9292

9393
}
9494

@@ -104,7 +104,7 @@ default Mono<ResponseEntity<BigDecimal>> fakeOuterNumberSerialize(Mono<BigDecima
104104
ServerWebExchange exchange) {
105105
Mono<Void> result = Mono.empty();
106106
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
107-
return result.then(Mono.empty());
107+
return result.then(body).then(Mono.empty());
108108

109109
}
110110

@@ -120,7 +120,7 @@ default Mono<ResponseEntity<String>> fakeOuterStringSerialize(Mono<String> body,
120120
ServerWebExchange exchange) {
121121
Mono<Void> result = Mono.empty();
122122
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
123-
return result.then(Mono.empty());
123+
return result.then(body).then(Mono.empty());
124124

125125
}
126126

@@ -136,7 +136,7 @@ default Mono<ResponseEntity<Void>> testBodyWithFileSchema(Mono<FileSchemaTestCla
136136
ServerWebExchange exchange) {
137137
Mono<Void> result = Mono.empty();
138138
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
139-
return result.then(Mono.empty());
139+
return result.then(body).then(Mono.empty());
140140

141141
}
142142

@@ -153,7 +153,7 @@ default Mono<ResponseEntity<Void>> testBodyWithQueryParams(String query,
153153
ServerWebExchange exchange) {
154154
Mono<Void> result = Mono.empty();
155155
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
156-
return result.then(Mono.empty());
156+
return result.then(body).then(Mono.empty());
157157

158158
}
159159

@@ -176,7 +176,7 @@ default Mono<ResponseEntity<Client>> testClientModel(Mono<Client> body,
176176
break;
177177
}
178178
}
179-
return result.then(Mono.empty());
179+
return result.then(body).then(Mono.empty());
180180

181181
}
182182

@@ -291,7 +291,7 @@ default Mono<ResponseEntity<Void>> testInlineAdditionalProperties(Mono<Map<Strin
291291
ServerWebExchange exchange) {
292292
Mono<Void> result = Mono.empty();
293293
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
294-
return result.then(Mono.empty());
294+
return result.then(param).then(Mono.empty());
295295

296296
}
297297

samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/FakeClassnameTestApiDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ default Mono<ResponseEntity<Client>> testClassname(Mono<Client> body,
4646
break;
4747
}
4848
}
49-
return result.then(Mono.empty());
49+
return result.then(body).then(Mono.empty());
5050

5151
}
5252

samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/PetApiDelegate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ default Mono<ResponseEntity<Void>> addPet(Mono<Pet> body,
4141
ServerWebExchange exchange) {
4242
Mono<Void> result = Mono.empty();
4343
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
44-
return result.then(Mono.empty());
44+
return result.then(body).then(Mono.empty());
4545

4646
}
4747

@@ -167,7 +167,7 @@ default Mono<ResponseEntity<Void>> updatePet(Mono<Pet> body,
167167
ServerWebExchange exchange) {
168168
Mono<Void> result = Mono.empty();
169169
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
170-
return result.then(Mono.empty());
170+
return result.then(body).then(Mono.empty());
171171

172172
}
173173

samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/StoreApiDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ default Mono<ResponseEntity<Order>> placeOrder(Mono<Order> body,
113113
break;
114114
}
115115
}
116-
return result.then(Mono.empty());
116+
return result.then(body).then(Mono.empty());
117117

118118
}
119119

samples/openapi3/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/UserApiDelegate.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ default Mono<ResponseEntity<Void>> createUser(Mono<User> body,
4141
ServerWebExchange exchange) {
4242
Mono<Void> result = Mono.empty();
4343
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
44-
return result.then(Mono.empty());
44+
return result.then(body).then(Mono.empty());
4545

4646
}
4747

@@ -56,7 +56,7 @@ default Mono<ResponseEntity<Void>> createUsersWithArrayInput(Flux<User> body,
5656
ServerWebExchange exchange) {
5757
Mono<Void> result = Mono.empty();
5858
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
59-
return result.then(Mono.empty());
59+
return result.thenMany(body).then(Mono.empty());
6060

6161
}
6262

@@ -71,7 +71,7 @@ default Mono<ResponseEntity<Void>> createUsersWithListInput(Flux<User> body,
7171
ServerWebExchange exchange) {
7272
Mono<Void> result = Mono.empty();
7373
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
74-
return result.then(Mono.empty());
74+
return result.thenMany(body).then(Mono.empty());
7575

7676
}
7777

@@ -167,7 +167,7 @@ default Mono<ResponseEntity<Void>> updateUser(String username,
167167
ServerWebExchange exchange) {
168168
Mono<Void> result = Mono.empty();
169169
exchange.getResponse().setStatusCode(HttpStatus.NOT_IMPLEMENTED);
170-
return result.then(Mono.empty());
170+
return result.then(body).then(Mono.empty());
171171

172172
}
173173

samples/server/petstore/springboot-reactive/src/main/java/org/openapitools/api/AnotherFakeApiDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ default Mono<ResponseEntity<Client>> call123testSpecialTags(Mono<Client> body,
4747
break;
4848
}
4949
}
50-
return result.then(Mono.empty());
50+
return result.then(body).then(Mono.empty());
5151

5252
}
5353

0 commit comments

Comments
 (0)