Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SpringCodegen extends AbstractJavaCodegen {
public static final String JAVA_8 = "java8";
public static final String ASYNC = "async";
public static final String RESPONSE_WRAPPER = "responseWrapper";
public static final String USE_TAGS = "useTags";
public static final String SPRING_MVC_LIBRARY = "spring-mvc";
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud";

Expand All @@ -29,6 +30,7 @@ public class SpringCodegen extends AbstractJavaCodegen {
protected boolean java8 = false;
protected boolean async = false;
protected String responseWrapper = "";
protected boolean useTags = false;

public SpringCodegen() {
super();
Expand All @@ -54,6 +56,7 @@ public SpringCodegen() {
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface"));
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
cliOptions.add(new CliOption(RESPONSE_WRAPPER, "wrap the responses in given type (Future,Callable,CompletableFuture,ListenableFuture,DeferredResult,HystrixCommand,RxObservable,RxSingle or fully qualified type)"));
cliOptions.add(CliOption.newBoolean(USE_TAGS, "use tags for creating interface and controller classnames"));

supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
Expand Down Expand Up @@ -124,6 +127,10 @@ public void processOpts() {
this.setResponseWrapper((String) additionalProperties.get(RESPONSE_WRAPPER));
}

if (additionalProperties.containsKey(USE_TAGS)) {
this.setUseTags(Boolean.valueOf(additionalProperties.get(USE_TAGS).toString()));
}

supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));

Expand Down Expand Up @@ -221,7 +228,7 @@ public void processOpts() {

@Override
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
if(library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_MVC_LIBRARY)) {
if((library.equals(DEFAULT_LIBRARY) || library.equals(SPRING_MVC_LIBRARY)) && !useTags) {
String basePath = resourcePath;
if (basePath.startsWith("/")) {
basePath = basePath.substring(1);
Expand Down Expand Up @@ -400,6 +407,10 @@ public void setSingleContentTypes(boolean singleContentTypes) {

public void setResponseWrapper(String responseWrapper) { this.responseWrapper = responseWrapper; }

public void setUseTags(boolean useTags) {
this.useTags = useTags;
}

@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SpringOptionsProvider extends JavaOptionsProvider {
public static final String JAVA_8 = "true";
public static final String ASYNC = "true";
public static final String RESPONSE_WRAPPER = "Callable";
public static final String USE_TAGS = "useTags";

@Override
public String getLanguage() {
Expand All @@ -34,6 +35,7 @@ public Map<String, String> createOptions() {
options.put(SpringCodegen.JAVA_8, JAVA_8);
options.put(SpringCodegen.ASYNC, ASYNC);
options.put(SpringCodegen.RESPONSE_WRAPPER, RESPONSE_WRAPPER);
options.put(SpringCodegen.USE_TAGS, USE_TAGS);

return options;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ protected void setExpectations() {
times = 1;
clientCodegen.setResponseWrapper(SpringOptionsProvider.RESPONSE_WRAPPER);
times = 1;
clientCodegen.setUseTags(Boolean.valueOf(SpringOptionsProvider.USE_TAGS));
times = 1;

}};
}
Expand Down