use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testConverterIssue17.
@Test
public void testConverterIssue17() throws Exception {
String yaml = "openapi: 3.0.0\n" + "info:\n" + " version: 0.0.0\n" + " title: nada\n" + "paths:\n" + " /persons:\n" + " get:\n" + " parameters:\n" + " - name: testParam\n" + " in: query\n" + " style: form\n" + " schema:\n" + " type: array\n" + " items:\n" + " type: string\n" + " responses:\n" + " '200':\n" + " description: Successful response\n" + " content:\n" + " '*/*':\n" + " schema:\n" + " $ref: '#/components/schemas/Content'\n" + "components:\n" + " schemas:\n" + " Content:\n" + " type: object";
ParseOptions options = new ParseOptions();
options.setResolve(false);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(yaml, null, options);
assertNotNull(result.getOpenAPI());
assertEquals((result.getOpenAPI().getPaths().get("/persons").getGet().getResponses().get("200").getContent().get("*/*").getSchema()).get$ref(), "#/components/schemas/Content");
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1190.
@Test
public void testIssue1190() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
SwaggerParseResult parseResult = openApiParser.readLocation("issue1190/issue1190.yaml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertNotNull(openAPI.getComponents().getSchemas().get("SomeObj_lorem"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testInlineModelResolver.
@Test
public void testInlineModelResolver(@Injectable final List<AuthorizationValue> auths) throws Exception {
String pathFile = FileUtils.readFileToString(new File("src/test/resources/flatten.json"));
pathFile = pathFile.replace("${dynamicPort}", String.valueOf(this.serverPort));
ParseOptions options = new ParseOptions();
options.setFlatten(true);
SwaggerParseResult result = new OpenAPIV3Parser().readContents(pathFile, auths, options);
Assert.assertNotNull(result);
OpenAPI openAPI = result.getOpenAPI();
Assert.assertNotNull(openAPI);
Schema user = openAPI.getComponents().getSchemas().get("User");
assertNotNull(user);
Schema address = (Schema) user.getProperties().get("address");
assertTrue((address.get$ref() != null));
Schema userAddress = openAPI.getComponents().getSchemas().get("User_address");
assertNotNull(userAddress);
assertNotNull(userAddress.getProperties().get("city"));
assertNotNull(userAddress.getProperties().get("street"));
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssueFlattenComposedSchemaInlineModelFlagFalse.
@Test
public void testIssueFlattenComposedSchemaInlineModelFlagFalse() {
OpenAPIV3Parser openApiParser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
options.setFlatten(true);
options.setFlattenComposedSchemas(false);
SwaggerParseResult parseResult = openApiParser.readLocation("FlattenComposedSchemasAtComponents.yaml", null, options);
OpenAPI openAPI = parseResult.getOpenAPI();
assertNotNull(openAPI);
assertNull(((ComposedSchema) openAPI.getComponents().getSchemas().get("contact-base-model")).getAllOf().get(0).get$ref());
assertNull(((ComposedSchema) openAPI.getComponents().getSchemas().get("Test")).getOneOf().get(1).get$ref());
}
use of io.swagger.v3.parser.core.models.ParseOptions in project swagger-parser by swagger-api.
the class OpenAPIV3ParserTest method testIssue1561.
@Test
public void testIssue1561() {
ParseOptions options = new ParseOptions();
options.setResolve(true);
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue-1561/swagger.yaml", null, options);
OpenAPI openAPI = result.getOpenAPI();
assertTrue(openAPI.getComponents().getResponses().size() == 3);
}
Aggregations