@Test public void testParsingPrettifiedExtensions() throws Exception { String json = "{\n" + " \"openapi\": \"3.0.1\",\n" + " \"x-some-extension\": \"some-value\"\n" + "}"; SwaggerParseResult result = new OpenAPIParser().readContents(json, null, null); assertNotNull(result); OpenAPI openAPI = result.getOpenAPI(); assertNotNull(openAPI); assertNotNull(openAPI.getExtensions()); assertEquals(openAPI.getExtensions().get("x-some-extension"), "some-value"); String prettyJson = Json.pretty(openAPI); SwaggerParseResult prettyResult = new OpenAPIParser().readContents(prettyJson, null, null); assertNotNull(prettyResult); OpenAPI prettyOpenAPI = prettyResult.getOpenAPI(); assertNotNull(prettyOpenAPI); assertNotNull(prettyOpenAPI.getExtensions()); assertEquals(prettyOpenAPI.getExtensions().get("x-some-extension"), "some-value"); }
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);  }