use of io.swagger.v3.jaxrs2.resources.model.Pet 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.jaxrs2.resources.model.Pet 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"));
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwayPetRefInSchemas.
@Test(description = "it should filter any Pet Ref in Schemas")
public void filterAwayPetRefInSchemas() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final OpenAPI filtered = new SpecFilter().filter(openAPI, new NoPetRefSchemaFilter(), null, null, null);
validateSchemasInComponents(filtered.getComponents(), PET_MODEL);
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-core by swagger-api.
the class JsonDeserializationTest method testDeserializeAResponseRef.
@Test
public void testDeserializeAResponseRef() throws Exception {
final OpenAPI oas = TestUtils.deserializeJsonFileFromClasspath("specFiles/responseRef.json", OpenAPI.class);
final ApiResponses responseMap = oas.getPaths().get("/pet").getPut().getResponses();
// TODO: missing response ref
assertIsRefResponse(responseMap.get("405"), "http://my.company.com/responses/errors.json#/method-not-allowed");
assertIsRefResponse(responseMap.get("404"), "http://my.company.com/responses/errors.json#/not-found");
assertTrue(responseMap.get("400") instanceof ApiResponse);
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-core by swagger-api.
the class JsonDeserializationTest method testExampleDeserializationOnMediaType.
@Test
public void testExampleDeserializationOnMediaType() throws Exception {
String content = FileUtils.readFileToString(new File("src/test/resources/specFiles/media-type-null-example.yaml"), "UTF-8");
OpenAPI openAPI = Yaml.mapper().readValue(content, OpenAPI.class);
assertNull(openAPI.getPaths().get("/pets/{petId}").getGet().getResponses().get("200").getContent().get("application/json").getExample());
assertTrue(openAPI.getPaths().get("/pets/{petId}").getGet().getResponses().get("200").getContent().get("application/json").getExampleSetFlag());
assertNull(openAPI.getPaths().get("/pet").getPost().getResponses().get("200").getContent().get("application/json").getExample());
assertFalse(openAPI.getPaths().get("/pet").getPost().getResponses().get("200").getContent().get("application/json").getExampleSetFlag());
assertNotNull(openAPI.getPaths().get("/pet").getPost().getRequestBody().getContent().get("application/json").getExample());
assertTrue(openAPI.getPaths().get("/pet").getPost().getRequestBody().getContent().get("application/json").getExampleSetFlag());
}
Aggregations