use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwayPathItemWithoutRef.
@Test(description = "it should filter any PathItem objects without Ref")
public void filterAwayPathItemWithoutRef() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final OpenAPI filtered = new SpecFilter().filter(openAPI, new NoPathItemFilter(), null, null, null);
assertEquals(0, filtered.getPaths().size());
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method cloneEverythingConcurrent.
@Test(description = "it should clone everything concurrently")
public void cloneEverythingConcurrent() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
ThreadGroup tg = new ThreadGroup("SpecFilterTest" + "|" + System.currentTimeMillis());
final Map<String, OpenAPI> filteredMap = new ConcurrentHashMap<>();
for (int i = 0; i < 10; i++) {
final int id = i;
new Thread(tg, "SpecFilterTest") {
public void run() {
try {
filteredMap.put("filtered " + id, new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null));
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
new Thread(new FailureHandler(tg, filteredMap, openAPI)).start();
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwayQueryParameters.
@Test(description = "it should filter any query parameter")
public void filterAwayQueryParameters() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final OpenAPI filtered = new SpecFilter().filter(openAPI, new NoParametersWithoutQueryInFilter(), null, null, null);
if (filtered.getPaths() != null) {
for (Map.Entry<String, PathItem> entry : filtered.getPaths().entrySet()) {
validateParameters(entry.getValue().getGet());
validateParameters(entry.getValue().getPost());
validateParameters(entry.getValue().getPut());
validateParameters(entry.getValue().getPatch());
validateParameters(entry.getValue().getHead());
validateParameters(entry.getValue().getDelete());
validateParameters(entry.getValue().getOptions());
}
}
}
use of io.swagger.v3.core.filter.SpecFilter 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.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method replaceGetResources.
@Test(description = "it should replace away with a new operation")
public void replaceGetResources() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
OpenAPI filter = new SpecFilter().filter(openAPI, new ReplaceGetOperationsFilter(), null, null, null);
assertOperations(filter, NEW_OPERATION_ID, NEW_OPERATION_DESCRIPTION);
}
Aggregations