-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from kicksolutions/add-information-to-readme
Add information to readme
- Loading branch information
Showing
6 changed files
with
143 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ons/swagger/plantuml/cliargs/CliArgs.java → ...va/com/kicksolutions/swagger/CliArgs.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
swagger2puml-core/src/main/java/com/kicksolutions/swagger/Swagger2PlantUML.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
swagger2puml-core/src/main/java/com/kicksolutions/swagger/plantuml/PlantUMLGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); | ||
} | ||
} |
109 changes: 0 additions & 109 deletions
109
swagger2puml-core/src/main/java/com/kicksolutions/swagger/plantuml/Swagger2PlantUML.java
This file was deleted.
Oops, something went wrong.