use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testCodegenIssue8601.
@Test
public void testCodegenIssue8601() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
SwaggerParseResult parseResult = openApiParser.readLocation("codegen-issue-8601.yaml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertNotNull(openAPI.getComponents().getSchemas().get("status"));
assertNotNull(openAPI.getComponents().getSchemas().get("test_body"));
assertNotNull(openAPI.getComponents().getSchemas().get("inline_response_200"));
assertNotNull(openAPI.getComponents().getSchemas().get("test_body_1"));
assertNotNull(openAPI.getComponents().getSchemas().get("Test1"));
assertNotNull(openAPI.getComponents().getSchemas().get("Test2"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1177.
@Test
public void testIssue1177(@Injectable final List<AuthorizationValue> auths) {
String path = "/issue-1177/swagger.yaml";
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().readLocation(path, auths, options).getOpenAPI();
// $ref response with $ref header
ApiResponse petsListApiResponse = openAPI.getPaths().get("/update-pets").getPost().getResponses().get("200");
assertNotNull(petsListApiResponse);
Header sessionIdHeader = petsListApiResponse.getHeaders().get("x-session-id");
assertNotNull(sessionIdHeader);
Schema petsListSchema = openAPI.getComponents().getSchemas().get("PetsList");
assertNotNull(petsListSchema);
assertNotNull(openAPI.getComponents().getHeaders());
Header sessionIdHeaderComponent = openAPI.getComponents().getHeaders().get("x-session-id");
assertTrue(sessionIdHeader == sessionIdHeaderComponent);
assertTrue(petsListApiResponse.getContent().get("application/json").getSchema() == petsListSchema);
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1148_Flatten_Dot.
@Test
public void testIssue1148_Flatten_Dot() {
ParseOptions options = new ParseOptions();
options.setFlatten(true);
SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue1148.yaml", null, options);
OpenAPI apispec = parseResult.getOpenAPI();
assertNotNull(apispec);
assertEquals(((Schema) apispec.getComponents().getSchemas().get("Some.User").getProperties().get("address")).get$ref(), "#/components/schemas/Some.User_address");
}
use of io.swagger.v3.parser.core.models.ParseOptions 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.core.models.ParseOptions 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());
}
Aggregations