use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testNotFlattenComposedSchema.
@Test
public void testNotFlattenComposedSchema() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
SwaggerParseResult parseResult = openApiParser.readLocation("flattenComposedSchemaComplete.json", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertNull(openAPI.getComponents().getSchemas().get("val_Members_val_member"));
assertNotNull(openAPI.getComponents().getSchemas().get("val_MemberProducts_val_product"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue948.
@Test
public void testIssue948() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("Issue_948.json", null, options);
new OpenAPIResolver(result.getOpenAPI()).resolve();
assertNotNull(result.getOpenAPI());
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method shouldParseApiWithMultipleParameterReferences.
@Test
public void shouldParseApiWithMultipleParameterReferences() {
// given
String location = "src/test/resources/issue-1063/api.yaml";
ParseOptions options = new ParseOptions();
OpenAPIV3Parser tested = new OpenAPIV3Parser();
// when
SwaggerParseResult result = tested.readLocation(location, emptyList(), options);
// then
OpenAPI api = result.getOpenAPI();
Map<String, Parameter> parameters = api.getComponents().getParameters();
assertThat(parameters.keySet(), equalTo(new HashSet<>(asList("IdParam", "NameParam"))));
assertThat(parameters.get("IdParam").getName(), equalTo("id"));
assertThat(parameters.get("NameParam").getName(), equalTo("name"));
assertThat(result.getMessages(), equalTo(emptyList()));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue915.
@Test
public void testIssue915() {
ParseOptions parseOptions = new ParseOptions();
parseOptions.setResolveFully(true);
OpenAPI openAPI = new OpenAPIV3Parser().read("src/test/resources/issue_918.yaml", null, parseOptions);
Map<String, Header> headers = openAPI.getPaths().get("/2.0/users/").getGet().getResponses().get("200").getHeaders();
String description = headers.get("X-Rate-Limit").getDescription();
assertEquals(description, "The number of allowed requests in the current period");
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testCantReadDeepProperties.
@Test
public void testCantReadDeepProperties() {
OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolveFully(true);
final SwaggerParseResult parseResult = parser.readLocation("src/test/resources/cant-read-deep-properties.yaml", null, options);
assertEquals(parseResult.getMessages().size(), 0);
Schema projects = (Schema) parseResult.getOpenAPI().getComponents().getSchemas().get("Project").getProperties().get("project_type");
assertEquals(projects.getType(), "integer");
}
Aggregations