use of io.swagger.v3.plugin.maven.resources.model.Pet in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testRelativePath2.
@Test
public void testRelativePath2() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult readResult = parser.readLocation("src/test/resources/codegen-remote-responses/openapi.yaml", null, options);
Assert.assertEquals(readResult.getOpenAPI().getPaths().get("/pet/findByTags").getGet().getResponses().get("default").getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/ErrorModel");
}
use of io.swagger.v3.plugin.maven.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.plugin.maven.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.plugin.maven.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.plugin.maven.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());
}
Aggregations