Search in sources :

Example 1 with NoOpOperationsFilter

use of io.swagger.v3.core.filter.resources.NoOpOperationsFilter 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();
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) OpenAPI(io.swagger.v3.oas.models.OpenAPI) NoOpOperationsFilter(io.swagger.v3.core.filter.resources.NoOpOperationsFilter) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 2 with NoOpOperationsFilter

use of io.swagger.v3.core.filter.resources.NoOpOperationsFilter 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"));
}
Also used : RemoveUnreferencedDefinitionsFilter(io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter) OpenAPI(io.swagger.v3.oas.models.OpenAPI) NoOpOperationsFilter(io.swagger.v3.core.filter.resources.NoOpOperationsFilter) Test(org.testng.annotations.Test)

Example 3 with NoOpOperationsFilter

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

the class SpecFilterTest method cloneWithoutModels.

@Test(description = "it should clone everything from JSON without models")
public void cloneWithoutModels() throws IOException {
    final String json = ResourceUtils.loadClassResource(getClass(), RESOURCE_PATH_WITHOUT_MODELS);
    final OpenAPI openAPI = Json.mapper().readValue(json, OpenAPI.class);
    final OpenAPI filtered = new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null);
    SerializationMatchers.assertEqualsToJson(filtered, json);
}
Also used : OpenAPI(io.swagger.v3.oas.models.OpenAPI) NoOpOperationsFilter(io.swagger.v3.core.filter.resources.NoOpOperationsFilter) Test(org.testng.annotations.Test)

Example 4 with NoOpOperationsFilter

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

the class SpecFilterTest method cloneEverything.

@Test(description = "it should clone everything")
public void cloneEverything() throws IOException {
    final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
    final OpenAPI filtered = new SpecFilter().filter(openAPI, new NoOpOperationsFilter(), null, null, null);
    assertEquals(Json.pretty(filtered), Json.pretty(openAPI));
}
Also used : OpenAPI(io.swagger.v3.oas.models.OpenAPI) NoOpOperationsFilter(io.swagger.v3.core.filter.resources.NoOpOperationsFilter) Test(org.testng.annotations.Test)

Example 5 with NoOpOperationsFilter

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

the class SpecFilterTest method shouldContainAllTopLevelTags.

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

Aggregations

NoOpOperationsFilter (io.swagger.v3.core.filter.resources.NoOpOperationsFilter)5 OpenAPI (io.swagger.v3.oas.models.OpenAPI)5 Test (org.testng.annotations.Test)5 RemoveUnreferencedDefinitionsFilter (io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter)1 IOException (java.io.IOException)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1