forked from loafle/openapi-generator-original
Spring-MVC config "j8-async": Uses async servlet & Java 8 interface
default This template is mainly for Maven code-gen plugin use-case - when Swagger spec on existing project changes there is no need to manually copy/paste the new functions from the generated client. This will provide a default (empty) implementation to existing impl and user just need to override the stub implementation. Because it generates an interface instead of a concrete stub, an implementation will be needed to actuate a service end-point. And don't forget to put @Controller on the implementation!
This commit is contained in:
@@ -18,12 +18,13 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
public static final String CONFIG_PACKAGE = "configPackage";
|
||||
protected String title = "Petstore Server";
|
||||
protected String configPackage = "";
|
||||
protected String templateFileName = "api.mustache";
|
||||
|
||||
public SpringMVCServerCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/javaSpringMVC";
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
apiTemplateFiles.put(templateFileName, ".java");
|
||||
embeddedTemplateDir = templateDir = "JavaSpringMVC";
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
@@ -51,6 +52,11 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
);
|
||||
|
||||
cliOptions.add(new CliOption(CONFIG_PACKAGE, "configuration package for generated code"));
|
||||
|
||||
supportedLibraries.clear();
|
||||
supportedLibraries.put(DEFAULT_LIBRARY, "Default Spring MVC server stub.");
|
||||
supportedLibraries.put("j8-async", "Use async servlet feature and Java 8's default interface. Generating interface with service " +
|
||||
"declaration is useful when using Maven plugin. Just provide a implementation with @Controller to instantiate service.");
|
||||
}
|
||||
|
||||
public CodegenType getTag() {
|
||||
@@ -168,6 +174,12 @@ public class SpringMVCServerCodegen extends JavaClientCodegen implements Codegen
|
||||
}
|
||||
}
|
||||
}
|
||||
if("j8-async".equals(getLibrary())) {
|
||||
apiTemplateFiles.remove(this.templateFileName);
|
||||
this.templateFileName = "api-j8-async.mustache";
|
||||
apiTemplateFiles.put(this.templateFileName, ".java");
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user