@Test public void testIssue1433_ResolveSchemaWithoutType() { OpenAPIParser openApiParser = new OpenAPIParser(); ParseOptions options = new ParseOptions(); options.setResolveFully(true); OpenAPI openAPI = openApiParser.readLocation("issue_1433-resolve-schema-without-type.yaml", null, options).getOpenAPI(); final Schema requestBodySchema = openAPI.getPaths().get("/foo").getPost().getRequestBody().getContent().get("application/json").getSchema(); assertNotNull(requestBodySchema); final Map properties = requestBodySchema.getProperties(); assertEquals(properties.size(), 2); final Object bar = properties.get("bar"); assertEquals(bar.getClass(), StringSchema.class); final Object input = properties.get("input"); assertEquals(input.getClass(), Schema.class); final Map inputProperties = ((Schema) input).getProperties(); assertNotNull(inputProperties); assertEquals(inputProperties.size(),1); final Object baz = inputProperties.get("baz"); assertEquals(baz.getClass(), StringSchema.class); }
public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readLocation(url, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; }
OpenAPIParser { public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readLocation(url, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; } }
OpenAPIParser { public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readLocation(url, auth, options); if(output != null && output.getOpenAPI() != null) { return output; } } return output; }  }
OpenAPIParser { public SwaggerParseResult readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readLocation(url, 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 readLocation(String url, List<AuthorizationValue> auth, ParseOptions options) { SwaggerParseResult output = null; for(SwaggerParserExtension extension : OpenAPIV3Parser.getExtensions()) { output = extension.readLocation(url, 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);  }