kasakrisz commented on a change in pull request #54: AMBARI-23456. Add mkdocs 
support & markdown skeletons
URL: https://github.com/apache/ambari-logsearch/pull/54#discussion_r239064714
 
 

 ##########
 File path: 
ambari-logsearch-docs/src/main/java/org/apache/ambari/logsearch/doc/LogSearchDocumentationGenerator.java
 ##########
 @@ -130,12 +140,32 @@ public static void main(String[] args) {
       File shipperConfigsOutputFile = Paths.get(outputDir, 
SHIPPER_CONFIGURATIONS_MARKDOWN_OUTPUT).toFile();
       writeMarkdown(freemarkerConfiguration, 
SHIPPER_CONFIGURATIONS_MARKDOWN_TEMPLATE_FILE, shipperConfigModels, 
shipperConfigsOutputFile);
 
+      String swaggerYaml = generateSwaggerYaml();
+      File swaggerYamlFile = Paths.get(outputDir, SWAGGER_API_DOC_FOLDER, 
SWAGGER_YAML_FILE_NAME).toFile();
+      FileUtils.writeStringToFile(swaggerYamlFile, swaggerYaml, 
Charset.defaultCharset());
     } catch (Exception e) {
       e.printStackTrace();
       System.exit(1);
     }
   }
 
+  private static String generateSwaggerYaml() throws Exception {
+    ApiDocConfig apiDocConfig = new ApiDocConfig();
+    BeanConfig beanConfig = apiDocConfig.swaggerConfig();
+    Swagger swagger = beanConfig.getSwagger();
+    swagger.addSecurityDefinition("basicAuth", new BasicAuthDefinition());
+    beanConfig.configure(swagger);
+    beanConfig.scanAndRead();
+    String yaml = Yaml.mapper().writeValueAsString(swagger);
+    StringBuilder b = new StringBuilder();
+    String[] parts = yaml.split("\n");
+    for (String part : parts) {
+      b.append(part);
+      b.append("\n");
+    }
+    return b.toString();
 
 Review comment:
   What is the difference between the result of `b.toString()` and `yaml` ?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to