rollback codegen template

This commit is contained in:
wing328 2015-06-09 13:04:03 +08:00
parent f610958209
commit 7b6480f7f8
3 changed files with 253 additions and 258 deletions

View File

@ -8,86 +8,85 @@ import java.io.File;
public class {{generatorClass}} extends DefaultCodegen implements CodegenConfig { public class {{generatorClass}} extends DefaultCodegen implements CodegenConfig {
// source folder where to write the files // source folder where to write the files
protected String sourceFolder = "src"; protected String sourceFolder = "src";
protected String apiVersion = "1.0.0"; protected String apiVersion = "1.0.0";
/** /**
* Configures the type of generator. * Configures the type of generator.
* *
* @return the CodegenType for this generator * @return the CodegenType for this generator
* @see io.swagger.codegen.CodegenType * @see io.swagger.codegen.CodegenType
*/ */
public CodegenType getTag() { public CodegenType getTag() {
return CodegenType.CLIENT; return CodegenType.CLIENT;
} }
/** /**
* Configures a friendly name for the generator. This will be used by the generator * Configures a friendly name for the generator. This will be used by the generator
* to select the library with the -l flag. * to select the library with the -l flag.
* *
* @return the friendly name for the generator * @return the friendly name for the generator
*/ */
public String getName() { public String getName() {
return "{{name}}"; return "{{name}}";
} }
/** /**
* Returns human-friendly help for the generator. Provide the consumer with help * Returns human-friendly help for the generator. Provide the consumer with help
* tips, parameters here * tips, parameters here
* *
* @return A string value for the help message * @return A string value for the help message
*/ */
public String getHelp() { public String getHelp() {
return "Generates a {{name}} client library."; return "Generates a {{name}} client library.";
} }
public {{generatorClass}}() { public {{generatorClass}}() {
super(); super();
// set the output folder here // set the output folder here
outputFolder = "generated-code/{{name}}"; outputFolder = "generated-code/{{name}}";
/** /**
* Models. You can write model files using the modelTemplateFiles map. * Models. You can write model files using the modelTemplateFiles map.
* if you want to create one template for file, you can do so here. * if you want to create one template for file, you can do so here.
* for multiple files for model, just put another entry in the `modelTemplateFiles` with * for multiple files for model, just put another entry in the `modelTemplateFiles` with
* a different extension * a different extension
*/ */
modelTemplateFiles.put( modelTemplateFiles.put(
"model.mustache", // the template to use "model.mustache", // the template to use
".sample"); // the extension for each file to write ".sample"); // the extension for each file to write
/** /**
* Api classes. You can write classes for each Api file with the apiTemplateFiles map. * Api classes. You can write classes for each Api file with the apiTemplateFiles map.
* as with models, add multiple entries with different extensions for multiple files per * as with models, add multiple entries with different extensions for multiple files per
* class * class
*/ */
apiTemplateFiles.put( apiTemplateFiles.put(
"api.mustache", // the template to use "api.mustache", // the template to use
".sample"); // the extension for each file to write ".sample"); // the extension for each file to write
/** /**
* Template Location. This is the location which templates will be read from. The generator * Template Location. This is the location which templates will be read from. The generator
* will use the resource stream to attempt to read the templates. * will use the resource stream to attempt to read the templates.
*/ */
templateDir = "{{name}}"; templateDir = "{{name}}";
/** /**
* Api Package. Optional, if needed, this can be used in templates * Api Package. Optional, if needed, this can be used in templates
*/ */
apiPackage = "io.swagger.client.api"; apiPackage = "io.swagger.client.api";
/** /**
* Model Package. Optional, if needed, this can be used in templates * Model Package. Optional, if needed, this can be used in templates
*/ */
modelPackage = "io.swagger.client.model"; modelPackage = "io.swagger.client.model";
/** /**
* Reserved words. Override this with reserved words specific to your language * Reserved words. Override this with reserved words specific to your language
*/ */
reservedWords = new HashSet reservedWords = new HashSet<String> (
<String> (
Arrays.asList( Arrays.asList(
"sample1", // replace with static values "sample1", // replace with static values
"sample2") "sample2")
@ -113,8 +112,7 @@ reservedWords = new HashSet
* Language Specific Primitives. These types will not trigger imports by * Language Specific Primitives. These types will not trigger imports by
* the client generator * the client generator
*/ */
languageSpecificPrimitives = new HashSet languageSpecificPrimitives = new HashSet<String>(
<String>(
Arrays.asList( Arrays.asList(
"Type1", // replace these with your types "Type1", // replace these with your types
"Type2") "Type2")
@ -190,4 +188,4 @@ reservedWords = new HashSet
type = swaggerType; type = swaggerType;
return toModelName(type); return toModelName(type);
} }
} }

View File

@ -57,8 +57,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/main/java</source>
src/main/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -70,8 +69,7 @@
</goals> </goals>
<configuration> <configuration>
<sources> <sources>
<source> <source>src/test/java</source>
src/test/java</source>
</sources> </sources>
</configuration> </configuration>
</execution> </execution>
@ -82,8 +80,7 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version> <version>2.3.2</version>
<configuration> <configuration>
<source> <source>1.6</source>
1.6</source>
<target>1.6</target> <target>1.6</target>
</configuration> </configuration>
</plugin> </plugin>