Skip to content

Commit 4cb07d2

Browse files
committed
Extended Fake Pet Store Specification with sse endpoint and added a new sample to check generation
1 parent 0da2bd9 commit 4cb07d2

File tree

119 files changed

+15284
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+15284
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
generatorName: spring
2+
outputDir: samples/server/petstore/springboot-reactive-serverSentEvents
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
5+
additionalProperties:
6+
groupId: org.openapitools.openapi3
7+
artifactId: springboot-reactive-serverSentEvents
8+
documentationProvider: springfox
9+
reactive: "true"
10+
hideGenerationTimestamp: "true"
11+
delegatePattern: "true"
12+
serverSentEvents: "true"

modules/openapi-generator/src/test/resources/3_0/spring/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,21 @@ paths:
11421142
application/json:
11431143
schema:
11441144
$ref: "#/components/schemas/ResponseObjectWithDifferentFieldNames"
1145+
/fake/sse:
1146+
get:
1147+
tags:
1148+
- fake
1149+
operationId: sse
1150+
responses:
1151+
200:
1152+
description: an sse endpoint
1153+
content:
1154+
text/event-stream:
1155+
schema:
1156+
type: array
1157+
format: event-stream
1158+
items:
1159+
$ref: "#/components/schemas/Pet"
11451160
servers:
11461161
- url: http://petstore.swagger.io:80/v2
11471162
components:

samples/client/petstore/spring-http-interface-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Map;
1515
import java.time.OffsetDateTime;
1616
import org.openapitools.model.OuterCompositeDto;
17+
import org.openapitools.model.PetDto;
1718
import org.openapitools.model.UserDto;
1819
import org.openapitools.model.XmlItemDto;
1920
import org.springframework.http.HttpStatus;
@@ -125,6 +126,22 @@ String fakeOuterStringSerialize(
125126
);
126127

127128

129+
/**
130+
* GET /fake/sse
131+
*
132+
* @return an sse endpoint (status code 200)
133+
*/
134+
@ResponseStatus(HttpStatus.OK)
135+
@HttpExchange(
136+
method = "GET",
137+
value = "/fake/sse",
138+
accept = { "text/event-stream" }
139+
)
140+
List<PetDto> sse(
141+
142+
);
143+
144+
128145
/**
129146
* PUT /fake/body-with-file-schema
130147
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

samples/client/petstore/spring-http-interface-reactive-noResponseEntity/src/main/java/org/openapitools/api/FakeApi.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Map;
1515
import java.time.OffsetDateTime;
1616
import org.openapitools.model.OuterComposite;
17+
import org.openapitools.model.Pet;
1718
import org.openapitools.model.User;
1819
import org.openapitools.model.XmlItem;
1920
import org.springframework.http.HttpStatus;
@@ -129,6 +130,22 @@ Mono<String> fakeOuterStringSerialize(
129130
);
130131

131132

133+
/**
134+
* GET /fake/sse
135+
*
136+
* @return an sse endpoint (status code 200)
137+
*/
138+
@ResponseStatus(HttpStatus.OK)
139+
@HttpExchange(
140+
method = "GET",
141+
value = "/fake/sse",
142+
accept = { "text/event-stream" }
143+
)
144+
Flux<Pet> sse(
145+
146+
);
147+
148+
132149
/**
133150
* PUT /fake/body-with-file-schema
134151
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

samples/client/petstore/spring-http-interface-reactive/src/main/java/org/openapitools/api/FakeApi.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Map;
1515
import java.time.OffsetDateTime;
1616
import org.openapitools.model.OuterComposite;
17+
import org.openapitools.model.Pet;
1718
import org.openapitools.model.User;
1819
import org.openapitools.model.XmlItem;
1920
import org.springframework.http.ResponseEntity;
@@ -124,6 +125,21 @@ Mono<ResponseEntity<String>> fakeOuterStringSerialize(
124125
);
125126

126127

128+
/**
129+
* GET /fake/sse
130+
*
131+
* @return an sse endpoint (status code 200)
132+
*/
133+
@HttpExchange(
134+
method = "GET",
135+
value = "/fake/sse",
136+
accept = { "text/event-stream" }
137+
)
138+
Mono<ResponseEntity<Flux<Pet>>> sse(
139+
140+
);
141+
142+
127143
/**
128144
* PUT /fake/body-with-file-schema
129145
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

samples/client/petstore/spring-http-interface/src/main/java/org/openapitools/api/FakeApi.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Map;
1515
import java.time.OffsetDateTime;
1616
import org.openapitools.model.OuterCompositeDto;
17+
import org.openapitools.model.PetDto;
1718
import org.openapitools.model.UserDto;
1819
import org.openapitools.model.XmlItemDto;
1920
import org.springframework.http.ResponseEntity;
@@ -120,6 +121,21 @@ ResponseEntity<String> fakeOuterStringSerialize(
120121
);
121122

122123

124+
/**
125+
* GET /fake/sse
126+
*
127+
* @return an sse endpoint (status code 200)
128+
*/
129+
@HttpExchange(
130+
method = "GET",
131+
value = "/fake/sse",
132+
accept = { "text/event-stream" }
133+
)
134+
ResponseEntity<List<PetDto>> sse(
135+
136+
);
137+
138+
123139
/**
124140
* PUT /fake/body-with-file-schema
125141
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

samples/openapi3/client/petstore/spring-cloud-oas3-fakeapi/src/main/java/org/openapitools/api/FakeApi.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.util.Map;
1515
import java.time.OffsetDateTime;
1616
import org.openapitools.model.OuterComposite;
17+
import org.openapitools.model.Pet;
1718
import org.openapitools.model.User;
1819
import org.openapitools.model.XmlItem;
1920
import io.swagger.v3.oas.annotations.ExternalDocumentation;
@@ -190,6 +191,31 @@ ResponseEntity<String> fakeOuterStringSerialize(
190191
);
191192

192193

194+
/**
195+
* GET /fake/sse
196+
*
197+
* @return an sse endpoint (status code 200)
198+
*/
199+
@Operation(
200+
operationId = "sse",
201+
tags = { "fake" },
202+
responses = {
203+
@ApiResponse(responseCode = "200", description = "an sse endpoint", content = {
204+
@Content(mediaType = "text/event-stream", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))
205+
})
206+
}
207+
)
208+
@RequestMapping(
209+
method = RequestMethod.GET,
210+
value = "/fake/sse",
211+
produces = { "text/event-stream" }
212+
)
213+
214+
ResponseEntity<List<Pet>> sse(
215+
216+
);
217+
218+
193219
/**
194220
* PUT /fake/body-with-file-schema
195221
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

samples/openapi3/server/petstore/springboot-delegate/src/main/java/org/openapitools/api/FakeApi.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.openapitools.model.ModelApiResponse;
1616
import java.time.OffsetDateTime;
1717
import org.openapitools.model.OuterComposite;
18+
import org.openapitools.model.Pet;
1819
import org.openapitools.model.ResponseObjectWithDifferentFieldNames;
1920
import org.openapitools.model.User;
2021
import org.openapitools.model.XmlItem;
@@ -230,6 +231,33 @@ default ResponseEntity<ResponseObjectWithDifferentFieldNames> responseObjectDiff
230231
}
231232

232233

234+
/**
235+
* GET /fake/sse
236+
*
237+
* @return an sse endpoint (status code 200)
238+
*/
239+
@Operation(
240+
operationId = "sse",
241+
tags = { "fake" },
242+
responses = {
243+
@ApiResponse(responseCode = "200", description = "an sse endpoint", content = {
244+
@Content(mediaType = "text/event-stream", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))
245+
})
246+
}
247+
)
248+
@RequestMapping(
249+
method = RequestMethod.GET,
250+
value = "/fake/sse",
251+
produces = { "text/event-stream" }
252+
)
253+
254+
default ResponseEntity<List<Pet>> sse(
255+
256+
) {
257+
return getDelegate().sse();
258+
}
259+
260+
233261
/**
234262
* PUT /fake/body-with-file-schema
235263
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.openapitools.model.ModelApiResponse;
1111
import java.time.OffsetDateTime;
1212
import org.openapitools.model.OuterComposite;
13+
import org.openapitools.model.Pet;
1314
import org.openapitools.model.ResponseObjectWithDifferentFieldNames;
1415
import org.openapitools.model.User;
1516
import org.openapitools.model.XmlItem;
@@ -132,6 +133,26 @@ default ResponseEntity<ResponseObjectWithDifferentFieldNames> responseObjectDiff
132133

133134
}
134135

136+
/**
137+
* GET /fake/sse
138+
*
139+
* @return an sse endpoint (status code 200)
140+
* @see FakeApi#sse
141+
*/
142+
default ResponseEntity<List<Pet>> sse() {
143+
getRequest().ifPresent(request -> {
144+
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
145+
if (mediaType.isCompatibleWith(MediaType.valueOf(""))) {
146+
String exampleString = "";
147+
ApiUtil.setExampleResponse(request, "", exampleString);
148+
break;
149+
}
150+
}
151+
});
152+
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
153+
154+
}
155+
135156
/**
136157
* PUT /fake/body-with-file-schema
137158
* For this test, the body for this request much reference a schema named &#x60;File&#x60;.

samples/openapi3/server/petstore/springboot-delegate/src/main/resources/openapi.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,25 @@ paths:
12841284
- application/json
12851285
x-tags:
12861286
- tag: pet
1287+
/fake/sse:
1288+
get:
1289+
operationId: sse
1290+
responses:
1291+
"200":
1292+
content:
1293+
text/event-stream:
1294+
schema:
1295+
format: event-stream
1296+
items:
1297+
$ref: '#/components/schemas/Pet'
1298+
type: array
1299+
description: an sse endpoint
1300+
tags:
1301+
- fake
1302+
x-accepts:
1303+
- text/event-stream
1304+
x-tags:
1305+
- tag: fake
12871306
components:
12881307
requestBodies:
12891308
UserArray:

0 commit comments

Comments
 (0)