use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssueSameRefsDifferentModel.
@Test
public void testIssueSameRefsDifferentModel() throws IOException {
String pathFile = FileUtils.readFileToString(new File("src/test/resources/same-refs-different-model-domain.yaml"), "UTF-8");
WireMock.stubFor(get(urlPathMatching("/issue-domain")).willReturn(aResponse().withStatus(HttpURLConnection.HTTP_OK).withHeader("Content-type", "application/json").withBody(pathFile.getBytes(StandardCharsets.UTF_8))));
pathFile = FileUtils.readFileToString(new File("src/test/resources/same-refs-different-model.yaml"), "UTF-8");
pathFile = pathFile.replace("${dynamicPort}", String.valueOf(this.serverPort));
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(true);
final SwaggerParseResult openAPI = parser.readContents(pathFile, null, options);
Yaml.prettyPrint(openAPI);
assertEquals(openAPI.getMessages().size(), 0);
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testResolveEmpty.
@Test
public void testResolveEmpty(@Injectable final List<AuthorizationValue> auths) throws Exception {
String pathFile = FileUtils.readFileToString(new File("src/test/resources/empty-oas.yaml"));
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(pathFile, auths, options);
Assert.assertNotNull(result);
Assert.assertNotNull(result.getOpenAPI());
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue357.
@Test
public void testIssue357() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
final OpenAPI openAPI = parser.read("src/test/resources/issue_357.yaml");
assertNotNull(openAPI);
List<Parameter> getParams = openAPI.getPaths().get("/testApi").getGet().getParameters();
assertEquals(2, getParams.size());
for (Parameter param : getParams) {
switch(param.getName()) {
case "pathParam1":
assertEquals(param.getSchema().getType(), "integer");
break;
case "pathParam2":
assertEquals(param.getSchema().getType(), "string");
break;
default:
fail("Unexpected parameter named " + param.getName());
break;
}
}
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue913.
@Test
public void testIssue913() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
final OpenAPI openAPI = parser.readLocation("issue-913/BS/ApiSpecification.yaml", null, options).getOpenAPI();
Assert.assertNotNull(openAPI);
Assert.assertNotNull(openAPI.getComponents().getSchemas().get("indicatorType"));
Assert.assertEquals(openAPI.getComponents().getSchemas().get("indicatorType").getProperties().size(), 1);
}
use of io.swagger.v3.parser.OpenAPIV3Parser in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testDiscriminatorSameFileExternalMapping.
@Test
public void testDiscriminatorSameFileExternalMapping() throws Exception {
OpenAPI openAPI = new OpenAPIV3Parser().read("./discriminator-mapping-resolution/main-external-mapping.yaml");
Assert.assertNotNull(openAPI);
Schema cat = openAPI.getComponents().getSchemas().get("Cat");
Assert.assertNotNull(cat);
}
Aggregations