use of io.swagger.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method shouldContainAllTopLevelTags.
@Test(description = "it should contain all tags in the top level Swagger object")
public void shouldContainAllTopLevelTags() throws IOException {
final Swagger swagger = getSwagger("specFiles/petstore.json");
final NoOpOperationsFilter filter = new NoOpOperationsFilter();
final Swagger filtered = new SpecFilter().filter(swagger, filter, null, null, null);
assertEquals(getTagNames(filtered), Sets.newHashSet("pet", "user", "store"));
}
use of io.swagger.core.filter.SpecFilter 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 Swagger swagger = getSwagger("specFiles/paramAndResponseRefComposed.json");
assertNotNull(swagger.getDefinitions().get("User"));
final NoOpOperationsFilter noOpfilter = new NoOpOperationsFilter();
Swagger filtered = new SpecFilter().filter(swagger, noOpfilter, null, null, null);
assertNotNull(filtered.getDefinitions().get("User"));
final RemoveUnreferencedDefinitionsFilter refFilter = new RemoveUnreferencedDefinitionsFilter();
filtered = new SpecFilter().filter(swagger, refFilter, null, null, null);
assertNotNull(filtered.getDefinitions().get("User"));
assertNotNull(filtered.getDefinitions().get("Pet"));
}
use of io.swagger.core.filter.SpecFilter 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 Swagger swagger = getSwagger("specFiles/sampleSpec.json");
final RemoveInternalParamsFilter filter = new RemoveInternalParamsFilter();
final Swagger filtered = new SpecFilter().filter(swagger, filter, null, null, null);
if (filtered.getPaths() != null) {
for (Map.Entry<String, Path> entry : filtered.getPaths().entrySet()) {
final Operation get = entry.getValue().getGet();
for (Parameter param : get.getParameters()) {
final String description = param.getDescription();
assertNotNull(description);
assertFalse(description.startsWith("secret"));
}
}
} else {
fail("paths should not be null");
}
}
use of io.swagger.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method shouldNotContainTopLevelUserTags.
@Test(description = "it should not contain user tags in the top level Swagger object")
public void shouldNotContainTopLevelUserTags() throws IOException {
final Swagger swagger = getSwagger("specFiles/petstore.json");
final NoUserOperationsFilter filter = new NoUserOperationsFilter();
final Swagger filtered = new SpecFilter().filter(swagger, filter, null, null, null);
assertEquals(getTagNames(filtered), Sets.newHashSet("pet", "store"));
}
use of io.swagger.core.filter.SpecFilter 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 Swagger swagger = getSwagger("specFiles/petstore.json");
swagger.setDefinitions(null);
final InternalModelPropertiesRemoverFilter filter = new InternalModelPropertiesRemoverFilter();
final Swagger filtered = new SpecFilter().filter(swagger, filter, null, null, null);
assertNotNull(filtered);
}
Aggregations