Skip to content

Commit

Permalink
chore: add a test for victools#499
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenberger committed Dec 10, 2024
1 parent 6492b14 commit e7f0ea8
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigPart;
import com.github.victools.jsonschema.generator.SchemaVersion;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
import org.json.JSONArray;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand Down Expand Up @@ -116,4 +118,20 @@ public void testSetStrictTypeInfo(String schemaInput, boolean considerNullType,
String schemaAsString = schema.toString();
JSONAssert.assertEquals('\n' + schemaAsString +'\n', expectedOutput, schemaAsString, JSONCompareMode.STRICT);
}

@Test
public void testAllOfCleanup() throws Exception {
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(
SchemaVersion.DRAFT_2019_09, OptionPreset.PLAIN_JSON);
SchemaCleanUpUtils utilsInstance = new SchemaCleanUpUtils(configBuilder.build());

JsonNode schema = configBuilder.getObjectMapper().readTree(
"{\"allOf\":[{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"string\"}},\"required\":[\"foo\"]},{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"string\"}},\"required\":[\"foo\"]}]}");
utilsInstance.reduceAllOfNodes(List.of((ObjectNode) schema));

String schemaAsString = schema.toString();
JSONAssert.assertEquals('\n' + schemaAsString + '\n',
"{\"type\":\"object\",\"properties\":{\"foo\":{\"type\":\"string\"}},\"required\":[\"foo\"]}",
schemaAsString, JSONCompareMode.STRICT);
}
}

0 comments on commit e7f0ea8

Please sign in to comment.