Java Code Examples for io.swagger.v3.parser.core.models.ParseOptions#setFlattenComposedSchemas()
The following examples show how to use
io.swagger.v3.parser.core.models.ParseOptions#setFlattenComposedSchemas() .
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: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 6 votes |
@Test public void testIssueFlattenAdditionalPropertiesSchemaInlineModelTrue() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(true); options.setCamelCaseFlattenNaming(true); SwaggerParseResult parseResult = openApiParser.readLocation("additionalPropertiesFlatten.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); //responses assertNotNull(openAPI.getComponents().getSchemas().get("Inline_response_map200")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_response_map200")).getOneOf().get(0).get$ref(),"#/components/schemas/Macaw1"); assertNotNull(openAPI.getComponents().getSchemas().get("Inline_response_map_items404")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_response_map_items404")).getAnyOf().get(0).get$ref(),"#/components/schemas/Macaw2"); }
Example 2
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testIssueFlattenArraySchemaItemsInlineModelFalse() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(false); options.setCamelCaseFlattenNaming(false); SwaggerParseResult parseResult = openApiParser.readLocation("flattenArrayItems.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); //responses assertNull(openAPI.getComponents().getSchemas().get("Inline_response_items200")); assertNull(openAPI.getComponents().getSchemas().get("Inline_response_400")); //parameters assertNull(openAPI.getComponents().getSchemas().get("Inline_parameter_items_bodylimit")); assertNull(openAPI.getComponents().getSchemas().get("Pagelimit")); //requestBodies assertNull(openAPI.getComponents().getSchemas().get("Body")); assertNull(openAPI.getComponents().getSchemas().get("Inline_response_items200")); //components assertNull(openAPI.getComponents().getSchemas().get("Inline_array_items_ArrayTest")); }
Example 3
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testIssueFlattenArraySchemaItemsInlineModelTrue() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(true); options.setCamelCaseFlattenNaming(true); SwaggerParseResult parseResult = openApiParser.readLocation("flattenArrayItems.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); //responses assertNotNull(openAPI.getComponents().getSchemas().get("Inline_response_items200")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_response_items200")).getAnyOf().get(0).get$ref(),"#/components/schemas/Macaw"); assertNotNull(openAPI.getComponents().getSchemas().get("Inline_response_400")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_response_400")).getAnyOf().get(0).get$ref(),"#/components/schemas/Macaw3"); //parameters assertNotNull(openAPI.getComponents().getSchemas().get("Inline_parameter_items_bodylimit")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_parameter_items_bodylimit")).getAnyOf().get(0).get$ref(),"#/components/schemas/Macaw1"); assertNotNull(openAPI.getComponents().getSchemas().get("Pagelimit")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Pagelimit")).getOneOf().get(0).get$ref(),"#/components/schemas/Macaw2"); //requestBodies assertNotNull(openAPI.getComponents().getSchemas().get("Body")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Body")).getAllOf().get(1).get$ref(),"#/components/schemas/requestBodiesAllOf_2"); assertNotNull(openAPI.getComponents().getSchemas().get("Inline_response_items200")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_body_items_applicationxml_requestBodies")).getAllOf().get(1).get$ref(),"#/components/schemas/ApplicationxmlAllOf_2"); //components assertNotNull(openAPI.getComponents().getSchemas().get("Inline_array_items_ArrayTest")); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Inline_array_items_ArrayTest")).getOneOf().get(1).get$ref(),"#/components/schemas/ArrayTestOneOf_2"); }
Example 4
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testCamelCaseFlattenNamingFalse() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(true); options.setCamelCaseFlattenNaming(false); SwaggerParseResult parseResult = openApiParser.readLocation("FlattenComposedSchemasAtComponents.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); assertNotNull(openAPI); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("contact-base-model")).getAllOf().get(0).get$ref(),"#/components/schemas/contactbasemodelAllOf_1"); }
Example 5
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testIssueFlattenComposedSchemaInlineModel() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(true); options.setCamelCaseFlattenNaming(true); SwaggerParseResult parseResult = openApiParser.readLocation("FlattenComposedSchemasAtComponents.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); assertNotNull(openAPI); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("contact-base-model")).getAllOf().get(0).get$ref(),"#/components/schemas/ContactBaseModelAllOf_1"); assertEquals(((ComposedSchema)openAPI.getComponents().getSchemas().get("Test")).getOneOf().get(1).get$ref(),"#/components/schemas/TestOneOf_2"); }
Example 6
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testIssueFlattenComposedSchemaInlineModelFlagFalse() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(false); SwaggerParseResult parseResult = openApiParser.readLocation("FlattenComposedSchemasAtComponents.yaml", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); assertNotNull(openAPI); assertNull(((ComposedSchema)openAPI.getComponents().getSchemas().get("contact-base-model")).getAllOf().get(0).get$ref()); assertNull(((ComposedSchema)openAPI.getComponents().getSchemas().get("Test")).getOneOf().get(1).get$ref()); }
Example 7
Source File: OpenAPIV3ParserTest.java From swagger-parser with Apache License 2.0 | 5 votes |
@Test public void testFlattenComposedSchema() { OpenAPIV3Parser openApiParser = new OpenAPIV3Parser(); ParseOptions options = new ParseOptions(); options.setResolve(true); options.setFlatten(true); options.setFlattenComposedSchemas(true); SwaggerParseResult parseResult = openApiParser.readLocation("flattenComposedSchemaComplete.json", null, options); OpenAPI openAPI = parseResult.getOpenAPI(); assertNotNull(openAPI.getComponents().getSchemas().get("val_Members_val_member")); assertNotNull(openAPI.getComponents().getSchemas().get("val_MemberProducts_val_product")); }