Skip to content

Commit

Permalink
Removed unnecessary cast that crashes for 3.1 schema
Browse files Browse the repository at this point in the history
Fixes #4657

Extra: fixed yaml checks - yaml by default always uses \n separator
  • Loading branch information
zeldigas authored and frantuma committed Sep 23, 2024
1 parent 516610b commit f868cf1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -849,21 +849,21 @@ public static Optional<Schema> getSchemaFromAnnotation(
Class<?>[] schemaImplementations = schema.oneOf();
for (Class<?> schemaImplementation : schemaImplementations) {
Schema oneOfSchemaObject = resolveSchemaFromType(schemaImplementation, components, jsonViewAnnotation, openapi31, null, null, context);
((ComposedSchema) schemaObject).addOneOfItem(oneOfSchemaObject);
schemaObject.addOneOfItem(oneOfSchemaObject);
}
}
if (schema.anyOf().length > 0) {
Class<?>[] schemaImplementations = schema.anyOf();
for (Class<?> schemaImplementation : schemaImplementations) {
Schema anyOfSchemaObject = resolveSchemaFromType(schemaImplementation, components, jsonViewAnnotation, openapi31, null, null, context);
((ComposedSchema) schemaObject).addAnyOfItem(anyOfSchemaObject);
schemaObject.addAnyOfItem(anyOfSchemaObject);
}
}
if (schema.allOf().length > 0) {
Class<?>[] schemaImplementations = schema.allOf();
for (Class<?> schemaImplementation : schemaImplementations) {
Schema allOfSchemaObject = resolveSchemaFromType(schemaImplementation, components, jsonViewAnnotation, openapi31, null, null, context);
((ComposedSchema) schemaObject).addAllOfItem(allOfSchemaObject);
schemaObject.addAllOfItem(allOfSchemaObject);
}
}
if (schema.additionalProperties().equals(io.swagger.v3.oas.annotations.media.Schema.AdditionalPropertiesValue.TRUE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,11 @@ public void testBooleanAdditionalPropertiesSerialization() throws Exception{

openAPI = Yaml31.mapper().readValue(expectedYaml, OpenAPI.class);
ser = Yaml31.pretty(openAPI);
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
assertEquals(ser, expectedYaml);
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
openAPI = Yaml.mapper().readValue(expectedYaml, OpenAPI.class);
ser = Yaml.pretty(openAPI);
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
assertEquals(ser, expectedYaml);
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));

expectedJson = "{\n" +
Expand Down Expand Up @@ -1505,11 +1505,11 @@ public void testBooleanAdditionalPropertiesSerialization() throws Exception{

openAPI = Yaml31.mapper().readValue(expectedYaml, OpenAPI.class);
ser = Yaml31.pretty(openAPI);
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
assertEquals(ser, expectedYaml);
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
openAPI = Yaml.mapper().readValue(expectedYaml, OpenAPI.class);
ser = Yaml.pretty(openAPI);
assertEquals(ser, withJacksonSystemLineSeparator(expectedYaml));
assertEquals(ser, expectedYaml);
assertTrue(Boolean.TRUE.equals(openAPI.getComponents().getSchemas().get("test").getAdditionalProperties()));
}

Expand Down

0 comments on commit f868cf1

Please sign in to comment.