@Test public void testConverterWithFlatten() { String yaml = "swagger: \"2.0\"\n" + "info:\n" + " description: \"Foo\"\n" + " version: \"1.0.0\"\n" + "host: \"something.com\"\n" + "basePath: \"/\"\n" + "schemes:\n" + " - \"https\"\n" + "consumes:\n" + " - \"application/json\"\n" + "produces:\n" + " - \"application/json\"\n" + "paths:\n" + " /example:\n" + " get:\n" + " responses:\n" + " 200:\n" + " description: \"OK\"\n" + " schema:\n" + " $ref: \"#/definitions/Foo\"\n" + " parameters: []\n" + "definitions:\n" + " Foo:\n" + " type: \"object\"\n" + " required:\n" + " properties:\n" + " nested:\n" + " type: \"object\"\n" + " properties:\n" + " color:\n" + " type: \"string\""; ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); SwaggerParseResult result = new OpenAPIParser().readContents(yaml, null, options); OpenAPI openAPI = result.getOpenAPI(); assertEquals(openAPI.getComponents().getSchemas().size(), 2); }
public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readContents(swaggerAsString, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; }
OpenAPIParser { public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readContents(swaggerAsString, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; } }
OpenAPIParser { public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readContents(swaggerAsString, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; }  }
OpenAPIParser { public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readContents(swaggerAsString, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; }  SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options); SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options); }
OpenAPIParser { public SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readContents(swaggerAsString, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; }  SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options); SwaggerParseResult readContents(String swaggerAsString, List<AuthorizationValue> auth, ParseOptions options);  }