Skip to content

Commit

Permalink
test(OpenAPINormalizer): nullability normalization for 3.1 specs (Ope…
Browse files Browse the repository at this point in the history
…nAPITools#19714)

* test(OpenAPINormalizer): nullability normalization for 3.1 specs

* chore: samples
  • Loading branch information
joscha authored Sep 30, 2024
1 parent 2d57255 commit d68a186
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d68a186

Please sign in to comment.