Skip to content

Commit

Permalink
Merge pull request #33 from kicksolutions/add-information-to-readme
Browse files Browse the repository at this point in the history
Add information to readme
  • Loading branch information
santoshm1188 authored Dec 20, 2017
2 parents 242d5b8 + ff91db9 commit f408802
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 138 deletions.
4 changes: 0 additions & 4 deletions cfg/maven/CI/deploy-nexus-artifacts.sh

This file was deleted.

24 changes: 0 additions & 24 deletions cfg/maven/CI/deploy.sh

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kicksolutions.swagger.plantuml.cliargs;
package com.kicksolutions.swagger;

import java.util.HashMap;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.kicksolutions.swagger;

import java.util.logging.Logger;

import org.apache.commons.lang3.StringUtils;

import com.kicksolutions.swagger.plantuml.PlantUMLGenerator;

/**
* MSANTOSH
*
*/
public class Swagger2PlantUML
{
private static final Logger LOGGER = Logger.getLogger(Swagger2PlantUML.class.getName());
private static final String USAGE = new StringBuilder().append(" Usage: com.kicksolutions.swagger.plantuml.Swagger2PlantUML <options> \n")
.append(" -i <spec file> ")
.append(" -o <output directory> ")
.append(" -generateDefinitionModelOnly true/false; Default=false ")
.append(" -includeCardinality true/false; Default=true ")
.append(" -generateSvg true/false; Default=true ").toString();

public Swagger2PlantUML() {
super();
}

/**
*
* @param args
*/
public static void main( String[] args )
{
Swagger2PlantUML swagger2PlantUML = new Swagger2PlantUML();
swagger2PlantUML.init(args);
}

/**
*
* @param args
*/
private void init(String args[]){
LOGGER.entering(LOGGER.getName(), "init");

CliArgs cliArgs = new CliArgs(args);
String specFile = cliArgs.getArgumentValue("-i", "");
String output = cliArgs.getArgumentValue("-o","");
boolean generateDefinitionModelOnly = Boolean.parseBoolean(cliArgs.getArgumentValue("-generateDefinitionModelOnly","false"));
boolean includeCardinality = Boolean.parseBoolean(cliArgs.getArgumentValue("-includeCardinality","true"));
boolean generateSvg = Boolean.parseBoolean(cliArgs.getArgumentValue("-generateSvg", "true"));

if(StringUtils.isNotEmpty(specFile) && StringUtils.isNotEmpty(output)){
process(specFile, output,generateDefinitionModelOnly,includeCardinality,generateSvg);
}
else{
LOGGER.severe(USAGE);
}

LOGGER.exiting(LOGGER.getName(), "init");
}

/**
*
* @param specFile
* @param output
*/
private void process(String specFile,String output,boolean generateDefinitionModelOnly,boolean includeCardinality,boolean generateSvg){
PlantUMLGenerator generator = new PlantUMLGenerator();
generator.transformSwagger2Puml(specFile, output, generateDefinitionModelOnly, includeCardinality, generateSvg);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.kicksolutions.swagger.plantuml;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

import io.swagger.models.Swagger;
import io.swagger.parser.SwaggerParser;

/**
* MSANTOSH
*
*/
public class PlantUMLGenerator
{
private static final Logger LOGGER = Logger.getLogger(PlantUMLGenerator.class.getName());

public PlantUMLGenerator() {
super();
}

/**
*
* @param specFile
* @param output
*/
public void transformSwagger2Puml(String specFile,String output,boolean generateDefinitionModelOnly,boolean includeCardinality,boolean generateSvg){
LOGGER.entering(LOGGER.getName(), "transformSwagger2Puml");

File swaggerSpecFile = new File(specFile);
File targetLocation = new File(output);

if(swaggerSpecFile.exists() && !swaggerSpecFile.isDirectory()
&& targetLocation.exists() && targetLocation.isDirectory()) {

Swagger swaggerObject = new SwaggerParser().read(swaggerSpecFile.getAbsolutePath());
PlantUMLCodegen codegen = new PlantUMLCodegen(swaggerObject, targetLocation, generateDefinitionModelOnly, includeCardinality);
String pumlPath = null;

try{
LOGGER.info("Processing File --> "+ specFile);
pumlPath = codegen.generatePuml();
LOGGER.info("Sucessfully Create PUML !!!");

if(generateSvg)
{
generateUMLDiagram(pumlPath, targetLocation);
}
}
catch(Exception e){
LOGGER.log(Level.SEVERE, e.getMessage(),e);
throw new RuntimeException(e);
}
}else{
throw new RuntimeException("Spec File or Ouput Locations are not valid");
}

LOGGER.exiting(LOGGER.getName(), "transformSwagger2Puml");
}

/**
*
* @param pumlLocation
* @param targetLocation
* @throws IOException
* @throws InterruptedException
*/
private void generateUMLDiagram(String pumlLocation,File targetLocation) throws IOException, InterruptedException{
net.sourceforge.plantuml.Run.main(new String[]{"-tsvg","-o",targetLocation.getAbsolutePath(),"-I",pumlLocation});
}
}

This file was deleted.

0 comments on commit f408802

Please sign in to comment.