use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testOneOfExternalRefConflictName.
@Test
public void testOneOfExternalRefConflictName() throws Exception {
OpenAPI openAPI = new OpenAPIV3Parser().read("./oneof_name_conflict/oneOf-external-ref-name-conflict.yaml");
Assert.assertNotNull(openAPI);
Schema pet = openAPI.getComponents().getSchemas().get("Pet");
Assert.assertNotNull(pet);
Assert.assertTrue(pet.getDiscriminator().getMapping().containsKey("Cat"));
Assert.assertTrue(pet.getDiscriminator().getMapping().get("Cat").equals("#/components/schemas/Cat_1"));
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testComposedRefResolvingIssue628.
@Test
public void testComposedRefResolvingIssue628(@Injectable final List<AuthorizationValue> auths) throws Exception {
ParseOptions options = new ParseOptions();
options.setResolve(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("src/test/resources/composedSchemaRef.yaml", auths, options);
Assert.assertNotNull(openAPI);
Assert.assertTrue(openAPI.getComponents().getSchemas().size() == 5);
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Cat"));
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Dog"));
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Pet"));
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Lion"));
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("Bear"));
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue594.
@Test
public void testIssue594() {
String yaml = "openapi: 3.0.0\n" + "servers: []\n" + "paths:\n" + " /test:\n" + " post:\n" + " responses:\n" + " '200':\n" + " description: OK\n" + " requestBody:\n" + " content:\n" + " application/json:\n" + " schema:\n" + " type: array\n" + " minItems: 1\n" + " maxItems: 1\n" + " items:\n" + " $ref: \"#/components/schemas/Pet\"\n" + " description: Hello world\n" + "info:\n" + " version: ''\n" + " title: ''";
SwaggerParseResult result = new OpenAPIV3Parser().readContents(yaml, null, null);
assertNotNull(result.getOpenAPI());
ArraySchema schema = (ArraySchema) (result.getOpenAPI().getPaths().get("/test").getPost().getRequestBody().getContent().get("application/json").getSchema());
assertEquals(schema.getItems().get$ref(), "#/components/schemas/Pet");
assertNotNull(schema.getMaxItems());
assertNotNull(schema.getMinItems());
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testParameterRequired.
@Test(description = "Test (path & form) parameter's required attribute")
public void testParameterRequired() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
final OpenAPI openAPI = parser.read("src/test/resources/petstore.yaml");
final List<Parameter> operationParams = openAPI.getPaths().get("/pet/{petId}").getPost().getParameters();
final PathParameter pathParameter = (PathParameter) operationParams.get(0);
Assert.assertTrue(pathParameter.getRequired());
}
use of io.swagger.v3.jaxrs2.resources.model.Pet in project swagger-core by swagger-api.
the class SpecFilterTest method filterAwayPetResource.
@Test(description = "it should filter away the pet resource")
public void filterAwayPetResource() throws IOException {
final OpenAPI openAPI = getOpenAPI(RESOURCE_PATH);
final NoPetOperationsFilter filter = new NoPetOperationsFilter();
final OpenAPI filtered = new SpecFilter().filter(openAPI, filter, null, null, null);
if (filtered.getPaths() != null) {
for (Map.Entry<String, PathItem> entry : filtered.getPaths().entrySet()) {
assertNull(entry.getValue().getDelete());
assertNull(entry.getValue().getPost());
assertNull(entry.getValue().getPut());
assertNull(entry.getValue().getGet());
assertNull(entry.getValue().getHead());
assertNull(entry.getValue().getOptions());
}
} else {
fail("paths should not be null");
}
}
Aggregations