Search in sources :

Example 1 with RemoveInternalParamsFilter

use of io.swagger.v3.core.filter.resources.RemoveInternalParamsFilter 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");
    }
}
Also used : PathItem(io.swagger.v3.oas.models.PathItem) Parameter(io.swagger.v3.oas.models.parameters.Parameter) Operation(io.swagger.v3.oas.models.Operation) RemoveInternalParamsFilter(io.swagger.v3.core.filter.resources.RemoveInternalParamsFilter) OpenAPI(io.swagger.v3.oas.models.OpenAPI) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.testng.annotations.Test)

Aggregations

RemoveInternalParamsFilter (io.swagger.v3.core.filter.resources.RemoveInternalParamsFilter)1 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1 Operation (io.swagger.v3.oas.models.Operation)1 PathItem (io.swagger.v3.oas.models.PathItem)1 Parameter (io.swagger.v3.oas.models.parameters.Parameter)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Test (org.testng.annotations.Test)1