use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method retainModelsReferencesFromAdditionalProperties.
@Test(description = "Retain models referenced from additonalProperties")
public void retainModelsReferencesFromAdditionalProperties() 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"));
assertNotNull(filtered.getComponents().getSchemas().get("ReferredOrder"));
}
use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method shouldRemoveBrokenRefs.
@Test
public void shouldRemoveBrokenRefs() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
openAPI.getPaths().get("/pet/{petId}").getGet().getResponses().getDefault().getHeaders().remove("X-Rate-Limit-Limit");
assertNotNull(openAPI.getComponents().getSchemas().get("PetHeader"));
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
assertNull(filtered.getComponents().getSchemas().get("PetHeader"));
assertNotNull(filtered.getComponents().getSchemas().get("Category"));
assertNotNull(filtered.getComponents().getSchemas().get("Pet"));
}
use of io.swagger.v3.core.filter.resources.RemoveUnreferencedDefinitionsFilter in project swagger-core by swagger-api.
the class SpecFilterTest method shouldRemoveBrokenNestedRefs.
@Test
public void shouldRemoveBrokenNestedRefs() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH_3303);
openAPI.getPaths().get("/pet/{petId}").getGet().getResponses().getDefault().getHeaders().remove("X-Rate-Limit-Limit");
assertNotNull(openAPI.getComponents().getSchemas().get("PetHeader"));
final RemoveUnreferencedDefinitionsFilter remover = new RemoveUnreferencedDefinitionsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, remover, null, null, null);
assertNull(filtered.getComponents().getSchemas().get("PetHeader"));
assertNull(filtered.getComponents().getSchemas().get("Bar"));
assertNotNull(filtered.getComponents().getSchemas().get("Category"));
assertNotNull(filtered.getComponents().getSchemas().get("Pet"));
assertNotNull(filtered.getComponents().getSchemas().get("Foo"));
assertNotNull(filtered.getComponents().getSchemas().get("allOfChild"));
assertNotNull(filtered.getComponents().getSchemas().get("anyOfChild"));
assertNotNull(filtered.getComponents().getSchemas().get("oneOfChild"));
assertNotNull(filtered.getComponents().getSchemas().get("allOfparentA"));
assertNotNull(filtered.getComponents().getSchemas().get("allOfparentB"));
assertNotNull(filtered.getComponents().getSchemas().get("anyOfparentA"));
assertNotNull(filtered.getComponents().getSchemas().get("anyOfparentB"));
assertNotNull(filtered.getComponents().getSchemas().get("oneOfparentA"));
assertNotNull(filtered.getComponents().getSchemas().get("oneOfparentB"));
assertNotNull(filtered.getComponents().getSchemas().get("oneOfNestedParentA"));
assertNotNull(filtered.getComponents().getSchemas().get("oneOfNestedParentB"));
assertNotNull(filtered.getComponents().getSchemas().get("discriminatorParent"));
assertNotNull(filtered.getComponents().getSchemas().get("discriminatorMatchedChildA"));
assertNotNull(filtered.getComponents().getSchemas().get("discriminatorRefProperty"));
assertNotNull(filtered.getComponents().getSchemas().get("discriminatorParentRefProperty"));
assertNotNull(filtered.getComponents().getSchemas().get("discriminatorMatchedChildB"));
}
Aggregations