Skip to content

Commit f868cf1

Browse files
zeldigasfrantuma
authored andcommitted
Removed unnecessary cast that crashes for 3.1 schema
Fixes #4657 Extra: fixed yaml checks - yaml by default always uses \n separator
1 parent 516610b commit f868cf1

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

modules/swagger-core/src/main/java/io/swagger/v3/core/util/AnnotationsUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,21 +849,21 @@ public static Optional<Schema> getSchemaFromAnnotation(
849849
Class<?>[] schemaImplementations = schema.oneOf();
850850
for (Class<?> schemaImplementation : schemaImplementations) {
851851
Schema oneOfSchemaObject = resolveSchemaFromType(schemaImplementation, components, jsonViewAnnotation, openapi31, null, null, context);
852-
((ComposedSchema) schemaObject).addOneOfItem(oneOfSchemaObject);
852+
schemaObject.addOneOfItem(oneOfSchemaObject);
853853
}
854854
}
855855
if (schema.anyOf().length > 0) {
856856
Class<?>[] schemaImplementations = schema.anyOf();
857857
for (Class<?> schemaImplementation : schemaImplementations) {
858858
Schema anyOfSchemaObject = resolveSchemaFromType(schemaImplementation, components, jsonViewAnnotation, openapi31, null, null, context);
859-
((ComposedSchema) schemaObject).addAnyOfItem(anyOfSchemaObject);
859+
schemaObject.addAnyOfItem(anyOfSchemaObject);
860860
}
861861
}
862862
if (schema.allOf().length > 0) {
863863
Class<?>[] schemaImplementations = schema.allOf();
864864
for (Class<?> schemaImplementation : schemaImplementations) {
865865
Schema allOfSchemaObject = resolveSchemaFromType(schemaImplementation, components, jsonViewAnnotation, openapi31, null, null, context);
866-
((ComposedSchema) schemaObject).addAllOfItem(allOfSchemaObject);
866+
schemaObject.addAllOfItem(allOfSchemaObject);
867867
}
868868
}
869869
if (schema.additionalProperties().equals(io.swagger.v3.oas.annotations.media.Schema.AdditionalPropertiesValue.TRUE)) {

modules/swagger-core/src/test/java/io/swagger/v3/core/serialization/OpenAPI3_1SerializationTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,11 +1468,11 @@ public void testBooleanAdditionalPropertiesSerialization() throws Exception{
14681468

14691469
openAPI = Yaml31.mapper().readValue(expectedYaml, OpenAPI.class);
14701470
ser = Yaml31.pretty(openAPI);
1471-
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
1471+
assertEquals(ser, expectedYaml);
14721472
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
14731473
openAPI = Yaml.mapper().readValue(expectedYaml, OpenAPI.class);
14741474
ser = Yaml.pretty(openAPI);
1475-
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
1475+
assertEquals(ser, expectedYaml);
14761476
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
14771477

14781478
expectedJson = "{\n" +
@@ -1505,11 +1505,11 @@ public void testBooleanAdditionalPropertiesSerialization() throws Exception{
15051505

15061506
openAPI = Yaml31.mapper().readValue(expectedYaml, OpenAPI.class);
15071507
ser = Yaml31.pretty(openAPI);
1508-
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
1508+
assertEquals(ser, expectedYaml);
15091509
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
15101510
openAPI = Yaml.mapper().readValue(expectedYaml, OpenAPI.class);
15111511
ser = Yaml.pretty(openAPI);
1512-
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
1512+
assertEquals(ser, expectedYaml);
15131513
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
15141514
}
15151515

0 commit comments

Comments
 (0)