Search in sources :

Example 1 with InternalModelPropertiesRemoverFilter

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

the class SpecFilterTest method filterWithNullDefinitions.

@Test(description = "it should filter with null definitions")
public void filterWithNullDefinitions() throws IOException {
    final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
    openAPI.getComponents().setSchemas(null);
    final InternalModelPropertiesRemoverFilter filter = new InternalModelPropertiesRemoverFilter();
    final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
    assertNotNull(filtered);
}
Also used : OpenAPI(io.swagger.v3.oas.models.OpenAPI) InternalModelPropertiesRemoverFilter(io.swagger.v3.core.filter.resources.InternalModelPropertiesRemoverFilter) Test(org.testng.annotations.Test)

Example 2 with InternalModelPropertiesRemoverFilter

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

the class SpecFilterTest method filterAwayInternalModelProperties.

@Test(description = "it should filter away internal model properties")
public void filterAwayInternalModelProperties() throws IOException {
    final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
    final InternalModelPropertiesRemoverFilter filter = new InternalModelPropertiesRemoverFilter();
    final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
    for (Map.Entry<String, Schema> entry : filtered.getComponents().getSchemas().entrySet()) {
        for (String propName : (Set<String>) entry.getValue().getProperties().keySet()) {
            assertFalse(propName.startsWith("_"));
        }
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Schema(io.swagger.v3.oas.models.media.Schema) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) InternalModelPropertiesRemoverFilter(io.swagger.v3.core.filter.resources.InternalModelPropertiesRemoverFilter) Test(org.testng.annotations.Test)

Aggregations

InternalModelPropertiesRemoverFilter (io.swagger.v3.core.filter.resources.InternalModelPropertiesRemoverFilter)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)2 Test (org.testng.annotations.Test)2 Schema (io.swagger.v3.oas.models.media.Schema)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1