### Question:
OpenApiModelParser { static JsonNode convertToJson(final String specification) throws IOException { final JsonNode specRoot; if (isJsonSpec(specification)) { specRoot = JsonUtils.reader().readTree(specification); } else { specRoot = JsonUtils.convertValue(YAML_PARSER.load(specification), JsonNode.class); } return specRoot; } private  OpenApiModelParser(); static OpenApiModelInfo parse(final String specification, final APIValidationContext validationContext); static boolean isJsonSpec(final String specification); static String resolve(URL url);  }### Answer:
@Test public void convertingToJsonShouldNotLooseSecurityDefinitions() throws IOException { final String definition = "{\"swagger\":\"2.0\",\"securityDefinitions\": {\n" + " \"api-key-header\": {\n" + " \"type\": \"apiKey\",\n" + " \"name\": \"API-KEY\",\n" + " \"in\": \"header\"\n" + " },\n" + " \"api-key-parameter\": {\n" + " \"type\": \"apiKey\",\n" + " \"name\": \"api_key\",\n" + " \"in\": \"query\"\n" + " }\n" + " }}"; final JsonNode node = OpenApiModelParser.convertToJson(definition); final JsonNode securityDefinitions = node.get("securityDefinitions"); assertThat(securityDefinitions.get("api-key-header")).isEqualTo(newNode() .put("type", "apiKey") .put("name", "API-KEY") .put("in", "header")); assertThat(securityDefinitions.get("api-key-parameter")).isEqualTo(newNode() .put("type", "apiKey") .put("name", "api_key") .put("in", "query")); }
@Test public void convertingToJsonShouldNotLooseSecurityRequirements() throws IOException { final String definition = "{\"swagger\":\"2.0\",\"paths\":{\"/api\":{\"get\":{\"security\":[{\"secured\":[\"scope\"]}]}}}}"; final JsonNode node = OpenApiModelParser.convertToJson(definition); assertThat(node.get("paths").get("/api").get("get").get("security")) .hasOnlyOneElementSatisfying(securityRequirement -> assertThat(securityRequirement.get("secured")) .hasOnlyOneElementSatisfying(scope -> assertThat(scope.asText()).isEqualTo("scope"))); }