Skip to content

Commit

Permalink
test(OpenAPINormalizer): nullability normalization for 3.1 specs
Browse files Browse the repository at this point in the history
  • Loading branch information
joscha committed Sep 29, 2024
1 parent 2d57255 commit fbf1266
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,24 @@ public void testOpenAPINormalizerProcessingArraySchema31Spec() {
assertEquals(((Schema) schema6.getProperties().get("arrayOfStrings")).getType(), "array");
}

@Test
public void testOpenAPINormalizerProcessingArraySchema31NullabilitySpec() {
OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_1/null-types-simple.yaml");
Schema schema = openAPI.getComponents().getSchemas().get("WithNullableType");

assertNull(((Schema) schema.getProperties().get("arrayDataOrNull")).getNullable());
assertNull(((Schema) schema.getProperties().get("stringDataOrNull")).getNullable());
assertNull(((Schema) schema.getProperties().get("oneofOrNull")).getNullable());

Map<String, String> inputRules = Map.of("NORMALIZE_31SPEC", "true");
OpenAPINormalizer openAPINormalizer = new OpenAPINormalizer(openAPI, inputRules);
openAPINormalizer.normalize();

assertTrue(((Schema) schema.getProperties().get("arrayDataOrNull")).getNullable());
assertTrue(((Schema) schema.getProperties().get("stringDataOrNull")).getNullable());
assertTrue(((Schema) schema.getProperties().get("oneofOrNull")).getNullable());
}

@Test
public void testOpenAPINormalizerSimplifyOneOfAnyOf31Spec() {
// to test the rule SIMPLIFY_ONEOF_ANYOF with 3.1 spec
Expand Down

0 comments on commit fbf1266

Please sign in to comment.