use of com.github.victools.jsonschema.generator.impl.SchemaCleanUpUtils in project jsonschema-generator by victools.
the class SchemaDefinitionNamingStrategyTest method testExampleStrategy.
@Test
@Parameters
@TestCaseName(value = "{method}({0}, {3} | {4}) [{index}]")
public void testExampleStrategy(String caseTitle, SchemaDefinitionNamingStrategy strategy, ResolvedType type, String expectedUriCompatibleName, String expectedPlainName) {
Mockito.when(this.key.getType()).thenReturn(type);
String result = strategy.getDefinitionNameForKey(this.key, this.generationContext);
// before the produced name is used in an actual schema, the SchemaCleanUpUtils come into play one way or another
SchemaCleanUpUtils cleanUpUtils = new SchemaCleanUpUtils(null);
Assert.assertEquals(expectedUriCompatibleName, cleanUpUtils.ensureDefinitionKeyIsUriCompatible(result));
Assert.assertEquals(expectedPlainName, cleanUpUtils.ensureDefinitionKeyIsPlain(result));
}
use of com.github.victools.jsonschema.generator.impl.SchemaCleanUpUtils in project jsonschema-generator by victools.
the class SchemaBuilder method performCleanup.
/**
* Reduce unnecessary structures in the generated schema definitions. Assumption being that this method is being invoked as the very last action
* of the schema generation.
*
* @see SchemaGeneratorConfig#shouldCleanupUnnecessaryAllOfElements()
* @see SchemaCleanUpUtils#reduceAllOfNodes(List)
* @see SchemaCleanUpUtils#reduceAnyOfNodes(List)
*/
private void performCleanup() {
SchemaCleanUpUtils cleanUpUtils = new SchemaCleanUpUtils(this.config);
if (this.config.shouldCleanupUnnecessaryAllOfElements()) {
cleanUpUtils.reduceAllOfNodes(this.schemaNodes);
}
cleanUpUtils.reduceAnyOfNodes(this.schemaNodes);
}
Aggregations