io.github.swagger2markup.Language Java Examples
The following examples show how to use
io.github.swagger2markup.Language.
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: Swagger2MarkupTest.java From SpringBootBucket with MIT License | 6 votes |
/** * 将swagger.yaml或swagger.json转换成漂亮的 AsciiDoc * 访问:http://localhost:9095/v2/api-docs * 将页面结果保存为src/main/resources/swagger.json */ private void convertAsciidoc(String swaggerStr) { // Path localSwaggerFile = Paths.get(System.getProperty("swaggerOutputDir"), "swagger.json"); Path outputFile = Paths.get(System.getProperty("asciiDocOutputDir")); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withMarkupLanguage(MarkupLanguage.ASCIIDOC) .withOutputLanguage(Language.ZH) .withPathsGroupedBy(GroupBy.TAGS) .withGeneratedExamples() .withoutInlineSchema() .build(); Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(swaggerStr) .withConfig(config) .build(); converter.toFile(outputFile); }
Example #2
Source File: SwaggerToAsciiDocMarkdownConfluence.java From springrestdoc with MIT License | 6 votes |
@Test public void test() throws URISyntaxException { //Given Path file = Paths.get(SwaggerToAsciiDocMarkdownConfluence.class.getResource(resource).toURI()); Path outputDirectory = Paths.get(BUILD_SWAGGER_2_MARKUP_PATH + outputPath); FileUtils.deleteQuietly(outputDirectory.toFile()); //When Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder() .withPathsGroupedBy(GroupBy.TAGS) .withOutputLanguage(Language.EN) .withMarkupLanguage(markupLanguage) .build(); Swagger2MarkupConverter.from(file) .withConfig(config) .build() .toFolder(outputDirectory); }
Example #3
Source File: Swagger2MarkupConfigBuilderTest.java From swagger2markup with Apache License 2.0 | 4 votes |
@Test public void testConfigOfDefaults() { Map<String, String> configMap = new HashMap<>(); configMap.put(Swagger2MarkupProperties.MARKUP_LANGUAGE, MarkupLanguage.MARKDOWN.toString()); configMap.put("swagger2markup.extensions.uniqueId1.customProperty1", "123"); configMap.put("swagger2markup.extensions.uniqueId1.customProperty2", "123"); configMap.put("swagger2markup.extensions.uniqueId2.customPropertyList1", "123,456"); configMap.put("swagger2markup.uniqueId1.customProperty1", "123"); configMap.put("swagger2markup.uniqueId1.customProperty2", "123"); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(configMap) .build(); assertThat(config.getAnchorPrefix()).isNull(); assertThat(config.getDefinitionOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getDefinitionOrdering()).isEqualTo(Ordering.natural()); assertThat(config.getDefinitionsDocument()).isEqualTo("definitions"); assertThat(config.isGeneratedExamplesEnabled()).isFalse(); assertThat(config.isInlineSchemaEnabled()).isEqualTo(true); assertThat(config.getInterDocumentCrossReferencesPrefix()).isNull(); assertThat(config.getMarkupLanguage().name()).isEqualTo(MarkupLanguage.MARKDOWN.name()); assertThat(config.getOperationOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getOperationOrdering()).isNotNull(); assertThat(config.getLanguage()).isEqualTo(Language.EN); assertThat(config.getOverviewDocument()).isEqualTo("overview"); assertThat(config.getParameterOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getParameterOrdering()).isEqualTo(Swagger2MarkupConfigBuilder.PARAMETER_IN_NATURAL_ORDERING.compound(Swagger2MarkupConfigBuilder.PARAMETER_NAME_NATURAL_ORDERING)); assertThat(config.getPathsDocument()).isEqualTo("paths"); assertThat(config.getPathsGroupedBy()).isEqualTo(GroupBy.AS_IS); assertThat(config.getPropertyOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getPropertyOrdering()).isEqualTo(Ordering.natural()); assertThat(config.getResponseOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getResponseOrdering()).isEqualTo(Ordering.natural()); assertThat(config.getSecurityDocument()).isEqualTo("security"); assertThat(config.getSeparatedDefinitionsFolder()).isEqualTo("definitions"); assertThat(config.getSeparatedOperationsFolder()).isEqualTo("operations"); assertThat(config.getTagOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getTagOrdering()).isEqualTo(Ordering.natural()); assertThat(config.isFlatBodyEnabled()).isFalse(); assertThat(config.isPathSecuritySectionEnabled()).isTrue(); assertThat(config.isInterDocumentCrossReferencesEnabled()).isFalse(); assertThat(config.isSeparatedDefinitionsEnabled()).isFalse(); assertThat(config.isSeparatedOperationsEnabled()).isFalse(); assertThat(config.getExtensionsProperties().getKeys()).hasSize(3) .containsOnly("uniqueId1.customProperty1", "uniqueId1.customProperty2", "uniqueId2.customPropertyList1" ); assertThat(config.getExtensionsProperties().getString("uniqueId1.customProperty1").get()).isEqualTo("123"); assertThat(config.getExtensionsProperties().getPathList("uniqueId2.customPropertyList1")).hasSize(1) .containsOnly(Paths.get("123,456")); }
Example #4
Source File: Swagger2MarkupConfigBuilderTest.java From swagger2markup with Apache License 2.0 | 4 votes |
@Test public void testConfigOfProperties() throws IOException { Properties properties = new Properties(); properties.load(Swagger2MarkupConfigBuilderTest.class.getResourceAsStream("/config/config.properties")); Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(properties).build(); assertThat(config.getAnchorPrefix()).isEqualTo("anchorPrefix"); assertThat(config.getDefinitionOrderBy()).isEqualTo(OrderBy.AS_IS); assertThat(config.getDefinitionOrdering()).isNull(); assertThat(config.getDefinitionsDocument()).isEqualTo("definitionsTest"); assertThat(config.isGeneratedExamplesEnabled()).isTrue(); assertThat(config.isHostnameEnabled()).isEqualTo(false); assertThat(config.isInlineSchemaEnabled()).isEqualTo(false); assertThat(config.getInterDocumentCrossReferencesPrefix()).isEqualTo("xrefPrefix"); assertThat(config.getMarkupLanguage().name()).isEqualTo(MarkupLanguage.MARKDOWN.name()); assertThat(config.getOperationOrderBy()).isEqualTo(OrderBy.NATURAL); assertThat(config.getOperationOrdering()).isEqualTo(Swagger2MarkupConfigBuilder.OPERATION_PATH_NATURAL_ORDERING.compound(Swagger2MarkupConfigBuilder.OPERATION_METHOD_NATURAL_ORDERING)); assertThat(config.getLanguage()).isEqualTo(Language.RU); assertThat(config.getOverviewDocument()).isEqualTo("overviewTest"); assertThat(config.getParameterOrderBy()).isEqualTo(OrderBy.AS_IS); assertThat(config.getParameterOrdering()).isNull(); assertThat(config.getPathsDocument()).isEqualTo("pathsTest"); assertThat(config.getPathsGroupedBy()).isEqualTo(GroupBy.TAGS); assertThat(config.getPropertyOrderBy()).isEqualTo(OrderBy.AS_IS); assertThat(config.getPropertyOrdering()).isNull(); assertThat(config.getResponseOrderBy()).isEqualTo(OrderBy.AS_IS); assertThat(config.getResponseOrdering()).isNull(); assertThat(config.getSecurityDocument()).isEqualTo("securityTest"); assertThat(config.getSeparatedDefinitionsFolder()).isEqualTo("definitionsTest"); assertThat(config.getSeparatedOperationsFolder()).isEqualTo("operationsTest"); assertThat(config.isListDelimiterEnabled()).isEqualTo(true); assertThat(config.getListDelimiter()).isEqualTo(Character.valueOf('|')); assertThat(config.getTagOrderBy()).isEqualTo(OrderBy.AS_IS); assertThat(config.getTagOrdering()).isNull(); assertThat(config.isFlatBodyEnabled()).isTrue(); assertThat(config.isPathSecuritySectionEnabled()).isFalse(); assertThat(config.isInterDocumentCrossReferencesEnabled()).isTrue(); assertThat(config.isSeparatedDefinitionsEnabled()).isTrue(); assertThat(config.isSeparatedOperationsEnabled()).isTrue(); assertThat(config.getExtensionsProperties().getKeys()).hasSize(5) .containsOnly("uniqueId1.customProperty1", "uniqueId1.customProperty2", "uniqueId2.customProperty1", "uniqueId2.customProperty2", "uniqueId2.customPropertyList1" ); assertThat(config.getExtensionsProperties().getPathList("uniqueId2.customPropertyList1")).hasSize(2) .containsOnly(Paths.get("123"), Paths.get("456")); }