use of io.swagger.v3.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 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"));
}
use of io.swagger.v3.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 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);
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method changeGetResources.
@Test(description = "it should change away with a new operation")
public void changeGetResources() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
OpenAPI filter = new SpecFilter().filter(openAPI, new ChangeGetOperationsFilter(), null, null, null);
assertOperations(filter, CHANGED_OPERATION_ID, CHANGED_OPERATION_DESCRIPTION);
}
use of io.swagger.v3.core.filter.SpecFilter 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);
}
use of io.swagger.v3.core.filter.SpecFilter in project swagger-core by swagger-api.
the class SpecFilterTest method removeUnreferencedModelOverride.
@Test(description = "broken references should not result in NPE")
public void removeUnreferencedModelOverride() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_REFERRED_SCHEMAS);
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
assertNotNull(filtered.getComponents().getSchemas().get("Order"));
}
Aggregations