use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method shouldNotRemoveGoodRefs.
@Test
public void shouldNotRemoveGoodRefs() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
assertNotNull(openAPI.getComponents().getSchemas().get("PetHeader"));
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
assertNotNull(filtered.getComponents().getSchemas().get("PetHeader"));
assertNotNull(filtered.getComponents().getSchemas().get("Category"));
}
use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method retainNonBrokenReferenceModelComposedProperties.
@Test(description = "it should retain non-broken reference model composed properties")
public void retainNonBrokenReferenceModelComposedProperties() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_REFERRED_SCHEMAS);
assertNotNull(openAPI.getComponents().getSchemas().get("User"));
final NoOpOperationsFilter noOperationsFilter = new NoOpOperationsFilter();
OpenAPI filtered = new SpecFilter().filter(openAPI, noOperationsFilter, null, null, null);
assertNotNull(filtered.getComponents().getSchemas().get("User"));
final RemoveUnreferencedDefinitionsFilter refFilter = new RemoveUnreferencedDefinitionsFilter();
filtered = new SpecFilter().filter(openAPI, refFilter, null, null, null);
assertNotNull(filtered.getComponents().getSchemas().get("User"));
assertNotNull(filtered.getComponents().getSchemas().get("Pet"));
}
use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method removeUnreferencedModelOverride.
@Test(description = "broken references should not result in NPE")
public void removeUnreferencedModelOverride() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_REFERRED_SCHEMAS);
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
assertNotNull(filtered.getComponents().getSchemas().get("Order"));
}
use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method removeUnreferencedDefinitionsOfRecuriveModels.
@Test(description = "recursive models, e.g. A-> A or A-> B and B -> A should not result in stack overflow")
public void removeUnreferencedDefinitionsOfRecuriveModels() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_RECURSIVE_MODELS);
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
assertNotNull(filtered.getComponents().getSchemas().get("SelfReferencingModel"));
assertNotNull(filtered.getComponents().getSchemas().get("IndirectRecursiveModelA"));
assertNotNull(filtered.getComponents().getSchemas().get("IndirectRecursiveModelB"));
}
use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method cloneRetainDeperecatedFlags.
@Test(description = "Clone should retain any 'deperecated' flags present on operations")
public void cloneRetainDeperecatedFlags() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_DEPRECATED_OPERATIONS);
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
Operation operation = filtered.getPaths().get("/test").getGet();
Boolean deprectedFlag = operation.getDeprecated();
assertNotNull(deprectedFlag);
assertEquals(deprectedFlag, Boolean.TRUE);
}
Aggregations