forked from loafle/openapi-generator-original
		
	updated static template
This commit is contained in:
		
							parent
							
								
									48f05b41e4
								
							
						
					
					
						commit
						d714f097eb
					
				| @ -69,6 +69,8 @@ public class Codegen extends DefaultGenerator { | ||||
|       return new JavaClientCodegen(); | ||||
|     else if("jaxrs".equals(name)) | ||||
|       return new JaxRSServerCodegen(); | ||||
|     else if("static".equals(name)) | ||||
|       return new StaticDocCodegen(); | ||||
|     else | ||||
|       throw new RuntimeException("unsupported client type"); | ||||
|   } | ||||
|  | ||||
| @ -35,7 +35,7 @@ public class DefaultGenerator implements Generator { | ||||
|     try { | ||||
|       config.processOpts(); | ||||
|       Map<String, Object> models = null; | ||||
|       Map<String, Object> operations = null; | ||||
|       List<Object> allOperations = new ArrayList<Object>(); | ||||
| 
 | ||||
|       // models | ||||
|       Map<String, Model> definitions = swagger.getDefinitions(); | ||||
| @ -66,11 +66,12 @@ public class DefaultGenerator implements Generator { | ||||
|       Map<String, List<CodegenOperation>> paths = processPaths(swagger.getPaths()); | ||||
|       for(String tag : paths.keySet()) { | ||||
|         List<CodegenOperation> ops = paths.get(tag); | ||||
| 
 | ||||
|         operations = processOperations(config, tag, ops); | ||||
|         operations.put("baseName", tag); | ||||
|         operations.put("modelPackage", config.modelPackage()); | ||||
|         operations.putAll(config.additionalProperties()); | ||||
|         Map<String, Object> operation = processOperations(config, tag, ops); | ||||
|         operation.put("baseName", tag); | ||||
|         operation.put("modelPackage", config.modelPackage()); | ||||
|         operation.putAll(config.additionalProperties()); | ||||
|         operation.put("classname", config.toApiName(tag)); | ||||
|         allOperations.add(operation); | ||||
|         for(String templateName : config.apiTemplateFiles().keySet()) { | ||||
|           String suffix = config.apiTemplateFiles().get(templateName); | ||||
|           String filename = config.apiFileFolder() + | ||||
| @ -88,7 +89,7 @@ public class DefaultGenerator implements Generator { | ||||
|             .defaultValue("") | ||||
|             .compile(template); | ||||
| 
 | ||||
|           writeToFile(filename, tmpl.execute(operations)); | ||||
|           writeToFile(filename, tmpl.execute(operation)); | ||||
|         } | ||||
|       } | ||||
| 
 | ||||
| @ -96,6 +97,11 @@ public class DefaultGenerator implements Generator { | ||||
|       Map<String, Object> bundle = new HashMap<String, Object>(); | ||||
|       bundle.putAll(config.additionalProperties()); | ||||
|       bundle.put("apiPackage", config.apiPackage()); | ||||
| 
 | ||||
|       Map<String, Object> apis = new HashMap<String, Object>(); | ||||
|       apis.put("apis", allOperations); | ||||
| 
 | ||||
|       bundle.put("apiInfo", apis); | ||||
|       for(SupportingFile support : config.supportingFiles()) { | ||||
|         String outputFolder = config.outputFolder(); | ||||
|         if(support.folder != null && !"".equals(support.folder)) | ||||
|  | ||||
| @ -7,7 +7,7 @@ import java.util.*; | ||||
| import java.io.File; | ||||
| 
 | ||||
| public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|   protected String invokerPackage = "com.wordnik.api"; | ||||
|   protected String invokerPackage = "com.wordnik.client"; | ||||
|   protected String groupId = "com.wordnik"; | ||||
|   protected String artifactId = "swagger-client"; | ||||
|   protected String artifactVersion = "1.0.0"; | ||||
| @ -19,8 +19,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|     modelTemplateFiles.put("model.mustache", ".java"); | ||||
|     apiTemplateFiles.put("api.mustache", ".java"); | ||||
|     templateDir = "Java"; | ||||
|     apiPackage = "com.wordnik.api"; | ||||
|     modelPackage = "com.wordnik.model"; | ||||
|     apiPackage = "com.wordnik.client.api"; | ||||
|     modelPackage = "com.wordnik.client.model"; | ||||
| 
 | ||||
|     additionalProperties.put("invokerPackage", invokerPackage); | ||||
|     additionalProperties.put("groupId", groupId); | ||||
|  | ||||
| @ -0,0 +1,64 @@ | ||||
| package com.wordnik.swagger.codegen.languages; | ||||
| 
 | ||||
| import com.wordnik.swagger.codegen.*; | ||||
| import com.wordnik.swagger.models.properties.*; | ||||
| 
 | ||||
| import java.util.*; | ||||
| import java.io.File; | ||||
| 
 | ||||
| public class StaticDocCodegen extends DefaultCodegen implements CodegenConfig { | ||||
|   protected String invokerPackage = "com.wordnik.client"; | ||||
|   protected String groupId = "com.wordnik"; | ||||
|   protected String artifactId = "swagger-client"; | ||||
|   protected String artifactVersion = "1.0.0"; | ||||
|   protected String sourceFolder = "docs"; | ||||
| 
 | ||||
|   public StaticDocCodegen() { | ||||
|     super(); | ||||
|     outputFolder = "docs"; | ||||
|     modelTemplateFiles.put("model.mustache", ".html"); | ||||
|     apiTemplateFiles.put("operation.mustache", ".html"); | ||||
|     templateDir = "swagger-static"; | ||||
| 
 | ||||
|     additionalProperties.put("invokerPackage", invokerPackage); | ||||
|     additionalProperties.put("groupId", groupId); | ||||
|     additionalProperties.put("artifactId", artifactId); | ||||
|     additionalProperties.put("artifactVersion", artifactVersion); | ||||
| 
 | ||||
|     supportingFiles.add(new SupportingFile("package.mustache", "", "package.json")); | ||||
|     supportingFiles.add(new SupportingFile("main.mustache", "", "main.js")); | ||||
|     supportingFiles.add(new SupportingFile("assets/css/bootstrap-responsive.css", | ||||
|       outputFolder + "/assets/css", "bootstrap-responsive.css")); | ||||
|     supportingFiles.add(new SupportingFile("assets/css/bootstrap.css", | ||||
|       outputFolder + "/assets/css", "bootstrap.css")); | ||||
|     supportingFiles.add(new SupportingFile("assets/css/style.css", | ||||
|       outputFolder + "/assets/css", "style.css")); | ||||
|     supportingFiles.add(new SupportingFile("assets/images/logo.png", | ||||
|       outputFolder + "/assets/images", "logo.png")); | ||||
|     supportingFiles.add(new SupportingFile("assets/js/bootstrap.js", | ||||
|       outputFolder + "/assets/js", "bootstrap.js")); | ||||
|     supportingFiles.add(new SupportingFile("assets/js/jquery-1.8.3.min.js", | ||||
|       outputFolder + "/assets/js", "jquery-1.8.3.min.js")); | ||||
|     supportingFiles.add(new SupportingFile("assets/js/main.js", | ||||
|       outputFolder + "/assets/js", "main.js")); | ||||
|     supportingFiles.add(new SupportingFile("index.mustache", | ||||
|       outputFolder, "index.html")); | ||||
| 
 | ||||
|     instantiationTypes.put("array", "ArrayList"); | ||||
|     instantiationTypes.put("map", "HashMap"); | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public String escapeReservedWord(String name) { | ||||
|     return "_" + name; | ||||
|   } | ||||
| 
 | ||||
|   @Override | ||||
|   public String apiFileFolder() { | ||||
|     return outputFolder + File.separator + sourceFolder + File.separator + "operations"; | ||||
|   } | ||||
| 
 | ||||
|   public String modelFileFolder() { | ||||
|     return outputFolder + File.separator + sourceFolder + File.separator + "models"; | ||||
|   } | ||||
| } | ||||
| @ -33,12 +33,12 @@ | ||||
|     		{{#apis}} | ||||
|         <div class="section-box"> | ||||
|           <div class="section-header"> | ||||
|             <a href="#!/{{className}}">{{className}}</a> | ||||
|             <a href="#!/{{classname}}">{{classname}}</a> | ||||
|           </div> | ||||
|           <ul> | ||||
| 			      {{#operations}} | ||||
| 			      {{#operation}} | ||||
|             <li><a href="#!/{{className}}#{{nickname}}">{{nickname}}</a></li> | ||||
|             <li><a href="#!/{{classname}}#{{nickname}}">{{nickname}}</a></li> | ||||
|             {{/operation}} | ||||
|             {{/operations}} | ||||
|           </ul> | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
|   {{#vars}} | ||||
| <ul class="parameter"> | ||||
|   <li class="param-required-{{required}}">{{name}} : {{datatype}} | ||||
| 	  <br/>{description}} | ||||
| 	  <br/>{{description}} | ||||
|   </li> | ||||
| </ul> | ||||
|   {{/vars}} | ||||
|  | ||||
| @ -706,9 +706,6 @@ | ||||
|         "status": { | ||||
|           "type": "string", | ||||
|           "position": 0 | ||||
|         }, | ||||
|         "complete": { | ||||
|           "type": "boolean" | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user