use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1071True.
@Test
public void testIssue1071True() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue-1071-true.yaml", null, options);
OpenAPI apispec = parseResult.getOpenAPI();
assertNotNull(apispec);
Schema test = apispec.getPaths().get("/mapschema").getGet().getResponses().get("200").getContent().get("application/json").getSchema();
assertTrue(test instanceof MapSchema);
assertTrue(test.getAdditionalProperties() instanceof Boolean);
assertTrue((Boolean) test.getAdditionalProperties());
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testLinkIssue.
@Test
public void testLinkIssue() {
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("src/test/resources/linkIssue.yaml", null, parseOptions);
Map<String, Link> links = openAPI.getPaths().get("/2.0/repositories/{username}").getGet().getResponses().get("200").getLinks();
Object requestBody = links.get("userRepository").getRequestBody();
assertEquals(requestBody, "$response.body#/slug");
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue286.
@Test
public void testIssue286() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
OpenAPI openAPI = parser.read("issue_286.yaml");
Schema response = openAPI.getPaths().get("/").getGet().getResponses().get("200").getContent().get("*/*").getSchema();
assertTrue(response.get$ref() != null);
assertEquals(response.get$ref(), "#/components/schemas/issue_286_PetList");
assertNotNull(openAPI.getComponents().getSchemas().get("issue_286_Allergy"));
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue255.
@Test
public void testIssue255() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
OpenAPI openAPI = parser.read("objectExample.yaml");
assertEquals(openAPI.getComponents().getSchemas().get("SamplePayload").getExample().toString(), "[{\"op\":\"replace\",\"path\":\"/s\",\"v\":\"w\"}]");
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testComposedSchemaAdjacent.
@Test
public void testComposedSchemaAdjacent(@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);
Schema schema = openAPI.getPaths().get("/path").getGet().getResponses().get("200").getContent().get("application/json").getSchema();
Assert.assertTrue(schema instanceof ComposedSchema);
ComposedSchema composedSchema = (ComposedSchema) schema;
Assert.assertTrue(composedSchema.getOneOf().size() == 2);
Assert.assertTrue(composedSchema.getAllOf().size() == 1);
}
Aggregations