Skip to content

Commit fd59e50

Browse files
author
Kathrin Geilmann
committed
Removed test scenario that cannot be implemented in a backward compatible way.
1 parent 0d931ef commit fd59e50

File tree

3 files changed

+13
-43
lines changed

3 files changed

+13
-43
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,21 +1034,19 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
10341034
content:
10351035
text/event-stream:
10361036
schema:
1037-
type: array
1038-
format: event-stream
1039-
items:
1040-
type: <type> or
1041-
$ref: <typeRef>
1037+
type: array
1038+
format: event-stream
1039+
items:
1040+
type: <type> or
1041+
$ref: <typeRef>
10421042
*/
10431043
Map<String, List<Schema>> schemaTypes = operation.getResponses().entrySet().stream()
10441044
.filter(p -> p.getValue().getContent() != null || p.getValue().get$ref() != null)
10451045
.map(e -> Pair.of(e.getValue(), fromResponse(e.getKey(), e.getValue())))
10461046
.filter(p -> p.getRight().is2xx) // consider only success
10471047
.map(p -> p.getLeft().getContent().get(MEDIA_EVENT_STREAM))
10481048
.filter(Objects::nonNull)
1049-
.map(MediaType::getSchema)
1050-
.map(s -> ModelUtils.unaliasSchema(openAPI, s))
1051-
.collect(Collectors.toList()).stream()
1049+
.map(s -> ModelUtils.unaliasSchema(openAPI, s.getSchema()))
10521050
.collect(Collectors.groupingBy(Schema::getType));
10531051
if(schemaTypes.containsKey("array")) {
10541052
// we have a match with SSE pattern

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4577,17 +4577,16 @@ public void testSSEOperationSupport() throws Exception {
45774577
@DataProvider(name = "invalid sse endpoints")
45784578
public static Object[][] specsWithInvalidSSEEndpoints() {
45794579
return new Object[][] {
4580-
{"sse_but_missing_format.yaml", "schema format 'event-stream' is required, when SSE is detected"},
4581-
// FIXME: spec does not generate correct code, but not detected
4582-
// {"sse_but_multiple_media_types.yaml", "only 1 response media type supported, when SSE is detected"},
4583-
{"sse_but_incompatible_item_types.yaml", "only single item type is supported, when SSE is detected"}
4580+
{"sse_but_missing_format.yaml", "schema format 'event-stream' is required"},
4581+
{"sse_but_incompatible_item_types.yaml", "only single item type is supported"}
45844582
};
45854583
}
45864584

45874585
@Test(dataProvider = "invalid sse endpoints")
45884586
public void testSSEOperationSupport_forInvalidSSEEndpointSpecs(String inputSpec, String expectedError) {
4589-
// checks the design decision, that if the specs looks like it should be an SSE endpoint but it is not
4590-
// matching the required format, an exception is thrown containing a descriptive error message
4587+
// checks the design decision, that if the specs looks like it should be an SSE endpoint, but it
4588+
// does not match the required format, an exception is thrown containing a descriptive error
4589+
// message
45914590
Map<String, Object> additionalProperties = Map.of(
45924591
SSE, true,
45934592
REACTIVE, "true",
@@ -4598,7 +4597,8 @@ public void testSSEOperationSupport_forInvalidSSEEndpointSpecs(String inputSpec,
45984597
assertThatThrownBy(() -> generateFromContract(input, "spring-boot", additionalProperties))
45994598
.rootCause()
46004599
.isInstanceOf(RuntimeException.class)
4601-
.hasMessage(expectedError);
4600+
.message()
4601+
.contains(expectedError);
46024602
}
46034603

46044604
@Test

modules/openapi-generator/src/test/resources/3_0/sse_but_multiple_media_types.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)