use of io.swagger.v3.core.filter.SpecFilter 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.SpecFilter 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);
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwaySecretParameters.
@Test(description = "it should filter away secret parameters")
public void filterAwaySecretParameters() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final RemoveInternalParamsFilter filter = new RemoveInternalParamsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
if (filtered.getPaths() != null) {
for (Map.Entry<String, PathItem> entry : filtered.getPaths().entrySet()) {
final Operation get = entry.getValue().getGet();
if (get != null) {
for (Parameter param : get.getParameters()) {
final String description = param.getDescription();
if (StringUtils.isNotBlank(description)) {
assertFalse(description.startsWith("secret"));
}
}
}
}
} else {
fail("paths should not be null");
}
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method retainModelsReferencesFromAdditionalProperties.
@Test(description = "Retain models referenced from additonalProperties")
public void retainModelsReferencesFromAdditionalProperties() 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"));
assertNotNull(filtered.getComponents().getSchemas().get("ReferredOrder"));
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwayOpenAPI.
@Test(description = "it should filter an openAPI object")
public void filterAwayOpenAPI() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final OpenAPI filtered = new SpecFilter().filter(openAPI, new NoOpenAPIFilter(), null, null, null);
assertNull(filtered);
}
Aggregations