Java Code Examples for io.swagger.v3.parser.core.models.ParseOptions#setResolveCombinators()
The following examples show how to use
io.swagger.v3.parser.core.models.ParseOptions#setResolveCombinators() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenAPIResolverTest.java From swagger-parser with Apache License 2.0 | 6 votes |
@Test public void resolveComposedSchema(@Injectable final List<AuthorizationValue> auths){ ParseOptions options = new ParseOptions(); options.setResolveCombinators(false); options.setResolveFully(true); OpenAPI openAPI = new OpenAPIV3Parser().readLocation("src/test/resources/oneof-anyof.yaml",auths,options).getOpenAPI(); assertTrue(openAPI.getPaths().get("/mixed-array").getGet().getResponses().get("200").getContent().get("application/json").getSchema() instanceof ArraySchema); ArraySchema arraySchema = (ArraySchema) openAPI.getPaths().get("/mixed-array").getGet().getResponses().get("200").getContent().get("application/json").getSchema(); assertTrue(arraySchema.getItems() instanceof ComposedSchema); ComposedSchema oneOf = (ComposedSchema) arraySchema.getItems(); assertEquals(oneOf.getOneOf().get(0).getType(), "string"); //System.out.println(openAPI.getPaths().get("/oneOf").getGet().getResponses().get("200").getContent().get("application/json").getSchema() ); assertTrue(openAPI.getPaths().get("/oneOf").getGet().getResponses().get("200").getContent().get("application/json").getSchema() instanceof ComposedSchema); ComposedSchema oneOfSchema = (ComposedSchema) openAPI.getPaths().get("/oneOf").getGet().getResponses().get("200").getContent().get("application/json").getSchema(); assertEquals(oneOfSchema.getOneOf().get(0).getType(), "object"); }
Example 2
Source File: StyleCheckParser.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
private static ParseOptions createParseOptions() { ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); parseOptions.setResolveCombinators(false); parseOptions.setResolveFully(false); parseOptions.setFlatten(false); return parseOptions; }
Example 3
Source File: SyntaxChecker.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
public static List<String> check(String oasSpecContent) { ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(false); parseOptions.setResolveFully(false); parseOptions.setResolveCombinators(false); parseOptions.setFlatten(false); OpenAPIV3Parser parser = new OpenAPIV3Parser(); SwaggerParseResult result = parser.readContents(oasSpecContent, null, parseOptions); return result.getMessages() == null ? emptyList() : result.getMessages(); }
Example 4
Source File: CompatibilityCheckParser.java From servicecomb-toolkit with Apache License 2.0 | 5 votes |
private static ParseOptions createParseOptions() { ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); parseOptions.setResolveCombinators(true); parseOptions.setResolveFully(true); parseOptions.setFlatten(false); return parseOptions; }
Example 5
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testIssue1367() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setResolveCombinators(true); options.setResolveFully(true); options.setFlatten(true); SwaggerParseResult parseResult = openApiParser.readLocation("issue-1367.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); assertTrue(((Schema)openAPI.getComponents().getSchemas().get("TestDTO").getProperties().get("choice")).getEnum() != null); }
Example 6
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testIssue1015() { ParseOptions options = new ParseOptions(); options.setResolve(true); options.setResolveCombinators(true); SwaggerParseResult parseResult = new OpenAPIV3Parser().readLocation("issue-1015.json", null, options); if (parseResult.getMessages() != null && !parseResult.getMessages().isEmpty()) { parseResult.getMessages().forEach(s -> System.out.println(s)); fail("Error while loading apispec!"); } OpenAPI apispec = parseResult.getOpenAPI(); assertNotNull(apispec); }
Example 7
Source File: OpenApi3Utils.java From vertx-web with Apache License 2.0 | 5 votes |
public static ParseOptions getParseOptions() { ParseOptions options = new ParseOptions(); options.setResolve(true); options.setResolveCombinators(false); options.setResolveFully(true); return options; }
Example 8
Source File: OpenAPI3ParametersUnitTest.java From vertx-web with Apache License 2.0 | 5 votes |
private OpenAPI loadSwagger(String filename) throws IOException { ParseOptions options = new ParseOptions(); options.setResolve(true); options.setResolveCombinators(false); options.setResolveFully(true); return new OpenAPIV3Parser().readContents(String.join("\n", Files.readAllLines(Paths.get(filename), StandardCharsets.UTF_8)), null, options).getOpenAPI(); }
Example 9
Source File: OpenAPIResolverTest.java From swagger-parser with Apache License 2.0 | 3 votes |
@Test public void resolveAllOfWithoutAggregatingParameters(@Injectable final List<AuthorizationValue> auths) { ParseOptions options = new ParseOptions(); options.setResolveFully(true); options.setResolveCombinators(false); // Testing components/schemas OpenAPI openAPI = new OpenAPIV3Parser().readLocation("src/test/resources/composed.yaml",auths,options).getOpenAPI(); ComposedSchema allOf = (ComposedSchema) openAPI.getComponents().getSchemas().get("ExtendedAddress"); assertEquals(allOf.getAllOf().size(), 2); assertTrue(allOf.getAllOf().get(0).getProperties().containsKey("street")); assertTrue(allOf.getAllOf().get(1).getProperties().containsKey("gps")); // Testing path item ComposedSchema schema = (ComposedSchema) openAPI.getPaths().get("/withInvalidComposedModel").getPost().getRequestBody().getContent().get("application/json").getSchema(); // In fact the schema resolved previously is the same of /withInvalidComposedModel assertEquals(schema, allOf); assertEquals(schema.getAllOf().size(), 2); assertTrue(schema.getAllOf().get(0).getProperties().containsKey("street")); assertTrue(schema.getAllOf().get(1).getProperties().containsKey("gps")); }