use of com.spectralogic.ds3autogen.java.JavaCodeGenerator in project ds3_autogen by SpectraLogic.
the class Main method run.
public void run() throws Exception {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
System.out.println("Generating " + args.getType().toString() + " ds3 sdk code for the spec " + args.getInputSpec());
//TODO make the input file also accept a url that we can read from
final Ds3ApiSpec spec = parser.getSpec(Files.newInputStream(Paths.get(args.getInputSpec())), args.generateInternal());
final CodeGenerator generator;
switch(args.getType()) {
case C:
generator = new CCodeGenerator();
break;
case JAVA:
generator = new JavaCodeGenerator();
break;
case NET:
generator = new NetCodeGenerator();
break;
case PYTHON:
generator = new PythonCodeGenerator();
break;
case PYTHON3:
generator = new Python3CodeGenerator();
break;
case GO:
generator = new GoCodeGenerator();
break;
default:
throw new IllegalArgumentException("Unknown generator typeName " + args.getType().toString());
}
final FileUtils fileUtils = new FileUtilsImpl();
final Ds3DocSpec docSpec;
if (args.isNoDoc()) {
docSpec = new Ds3DocSpecEmptyImpl();
} else {
final Ds3DocSpecParser docSpecParser = new Ds3DocSpecParserImpl(new NameMapper());
docSpec = docSpecParser.getDocSpec();
}
generator.generate(spec, fileUtils, Paths.get(args.getTargetDir()), docSpec);
}
use of com.spectralogic.ds3autogen.java.JavaCodeGenerator in project ds3_autogen by SpectraLogic.
the class TestGeneratedComponentResponseCode method generateCode.
@Override
public void generateCode(final FileUtils fileUtils, final String inputFileName) throws IOException, TemplateModelException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(TestGeneratedCode.class.getResourceAsStream(inputFileName));
final CodeGenerator codeGenerator = new JavaCodeGenerator();
codeGenerator.generate(spec, fileUtils, Paths.get("."), new Ds3DocSpecEmptyImpl());
requestGeneratedCode = new String(requestOutputStream.toByteArray());
responseGeneratedCode = new String(responseOutputStream.toByteArray());
responseParserGeneratedCode = new String(responseParserOutputStream.toByteArray());
encapsulatingTypeGeneratedCode = new String(encapsulatingTypeOutputStream.toByteArray());
ds3ClientGeneratedCode = new String(ds3ClientOutputStream.toByteArray());
ds3ClientImplGeneratedCode = new String(ds3ClientImplOutputStream.toByteArray());
}
use of com.spectralogic.ds3autogen.java.JavaCodeGenerator in project ds3_autogen by SpectraLogic.
the class TestGeneratedModelCode method generateCode.
public void generateCode(final FileUtils fileUtils, final String inputFileName) throws IOException, TemplateModelException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(TestGeneratedModelCode.class.getResourceAsStream(inputFileName));
final CodeGenerator codeGenerator = new JavaCodeGenerator();
codeGenerator.generate(spec, fileUtils, Paths.get("."), new Ds3DocSpecEmptyImpl());
modelGeneratedCode = new String(modelOutputStream.toByteArray());
}
use of com.spectralogic.ds3autogen.java.JavaCodeGenerator in project ds3_autogen by SpectraLogic.
the class TestGeneratedCode method generateCode.
public void generateCode(final FileUtils fileUtils, final String inputFileName, final Ds3DocSpec docSpec) throws IOException, TemplateModelException {
final Ds3SpecParser parser = new Ds3SpecParserImpl();
final Ds3ApiSpec spec = parser.getSpec(TestGeneratedCode.class.getResourceAsStream(inputFileName));
final CodeGenerator codeGenerator = new JavaCodeGenerator();
codeGenerator.generate(spec, fileUtils, Paths.get("."), docSpec);
requestGeneratedCode = new String(requestOutputStream.toByteArray());
responseGeneratedCode = new String(responseOutputStream.toByteArray());
responseParserGeneratedCode = new String(responseParserOutputStream.toByteArray());
ds3ClientGeneratedCode = new String(ds3ClientOutputStream.toByteArray());
ds3ClientImplGeneratedCode = new String(ds3ClientImplOutputStream.toByteArray());
}
Aggregations