use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method issueRelativeRefs2.
@Test
public void issueRelativeRefs2() throws Exception {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
final SwaggerParseResult result = parser.readLocation("src/test/resources/relative-upper-directory/swagger.yaml", null, options);
Assert.assertNotNull(result.getOpenAPI());
OpenAPI openAPI = result.getOpenAPI();
assertNotNull(openAPI.getPaths().get("/api/Address").getGet());
assertTrue(openAPI.getComponents().getSchemas().size() == 1);
assertNotNull(openAPI.getComponents().getSchemas().get("AddressEx"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1644_EmptyValue.
@Test
public void testIssue1644_EmptyValue() throws Exception {
ParseOptions options = new ParseOptions();
String issue1644 = "openapi: 3.0.0\n" + "info:\n" + " title: Operations\n" + " version: 0.0.0\n" + "paths:\n" + " \"/operations\":\n" + " post:\n" + " parameters:\n" + " - name: param0\n" + " in: ''\n" + " schema:\n" + " type: string\n" + " responses:\n" + " default:\n" + " description: None\n";
SwaggerParseResult result = new OpenAPIV3Parser().readContents(issue1644, null, options);
Assert.assertNotNull(result);
Assert.assertNotNull(result.getOpenAPI());
assertEquals(result.getMessages().size(), 1);
assertTrue(result.getMessages().contains("attribute paths.'/operations'(post).parameters.[param0].in is not of type `[query|header|path|cookie]`"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1039.
@Test
public void testIssue1039() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue_1039.yaml", null, options);
OpenAPI apispec = parseResult.getOpenAPI();
assertNotNull(apispec);
assertEquals(apispec.getPaths().get("/pets").getGet().getParameters().get(0).getSchema().getType(), "array");
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue_1292.
@Test
public void testIssue_1292() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue-1292/petstore.yml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertNotNull(openAPI.getPaths().get("/pets").getGet().getResponses().get("200").getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/Pets");
assertNotNull(openAPI.getPaths().get("/pets").getGet().getResponses().getDefault().getContent().get("application/json").getSchema().get$ref(), "#/components/schemas/Error");
assertNotNull(openAPI.getComponents().getSchemas().get("Pet"));
assertNotNull(openAPI.getComponents().getSchemas().get("Pets"));
assertNotNull(openAPI.getComponents().getSchemas().get("Error"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue901.
@Test
public void testIssue901() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
OpenAPI openAPI = new OpenAPIV3Parser().readLocation("issue-901/spec.yaml", null, options).getOpenAPI();
assertNotNull(openAPI);
String internalRef = openAPI.getPaths().get("/test").getPut().getResponses().get("200").getContent().get("application/json").getSchema().get$ref();
assertEquals(internalRef, "#/components/schemas/Test.Definition");
assertNotNull(openAPI.getComponents());
}
Aggregations