Search in sources :

Example 1 with NoPetOperationsFilter

use of io.swagger.v3.core.filter.resources.NoPetOperationsFilter in project swagger-core by swagger-api.

the class SpecFilterTest method filterAwayPetResource.

@Test(description = "it should filter away the pet resource")
public void filterAwayPetResource() throws IOException {
    final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
    final NoPetOperationsFilter filter = new NoPetOperationsFilter();
    final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
    if (filtered.getPaths() != null) {
        for (Map.Entry<String, PathItem> entry : filtered.getPaths().entrySet()) {
            assertNull(entry.getValue().getDelete());
            assertNull(entry.getValue().getPost());
            assertNull(entry.getValue().getPut());
            assertNull(entry.getValue().getGet());
            assertNull(entry.getValue().getHead());
            assertNull(entry.getValue().getOptions());
        }
    } else {
        fail("paths should not be null");
    }
}
Also used : PathItem(io.swagger.v3.oas.models.PathItem) OpenAPI(io.swagger.v3.oas.models.OpenAPI) NoPetOperationsFilter(io.swagger.v3.core.filter.resources.NoPetOperationsFilter) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.testng.annotations.Test)

Example 2 with NoPetOperationsFilter

use of io.swagger.v3.core.filter.resources.NoPetOperationsFilter in project swagger-core by swagger-api.

the class SpecFilterTest method shouldNotContainTopLevelUserTags.

@Test(description = "it should not contain user tags in the top level OpenAPI object")
public void shouldNotContainTopLevelUserTags() throws IOException {
    final OpenAPI openAPI = getOpenAPI(RESOURCE_REFERRED_SCHEMAS);
    final NoPetOperationsFilter filter = new NoPetOperationsFilter();
    final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
    assertEquals(getTagNames(filtered), Sets.newHashSet(USER_TAG, STORE_TAG));
}
Also used : OpenAPI(io.swagger.v3.oas.models.OpenAPI) NoPetOperationsFilter(io.swagger.v3.core.filter.resources.NoPetOperationsFilter) Test(org.testng.annotations.Test)

Aggregations

NoPetOperationsFilter (io.swagger.v3.core.filter.resources.NoPetOperationsFilter)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)2 Test (org.testng.annotations.Test)2 PathItem (io.swagger.v3.oas.models.PathItem)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1