forked from loafle/openapi-generator-original
* java 8 interface only delegate method mode * typo correction * Update samples with ./bin/spring-all-petstore.sh * change delegate prefix to "do" and make delegate method a default method that returns an OK status code * remove temp debug printout * prefix spring annotated method with "_" to indicate that is private * resolve merge issues from Merge of remote-tracking branch 'upstream/master' * tuned whitespace in api.mustache and re-ran spring-all-petstore.sh * removed special spring cloud library check as it was no longer being referenced in api.mustache re-ran spring-all-petstore.sh
This commit is contained in:
parent
cccef5dbc3
commit
ad7a8200f0
@ -39,6 +39,7 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
protected String basePackage = "io.swagger";
|
||||
protected boolean interfaceOnly = false;
|
||||
protected boolean delegatePattern = false;
|
||||
protected boolean delegateMethod = false;
|
||||
protected boolean singleContentTypes = false;
|
||||
protected boolean java8 = false;
|
||||
protected boolean async = false;
|
||||
@ -206,8 +207,14 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
|
||||
if (this.interfaceOnly && this.delegatePattern) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Can not generate code with `%s` and `%s` both true.", DELEGATE_PATTERN, INTERFACE_ONLY));
|
||||
if (this.java8) {
|
||||
this.delegateMethod = true;
|
||||
additionalProperties.put("delegate-method", true);
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Can not generate code with `%s` and `%s` true while `%s` is false.",
|
||||
DELEGATE_PATTERN, INTERFACE_ONLY, JAVA_8));
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.interfaceOnly) {
|
||||
@ -273,12 +280,12 @@ public class SpringCodegen extends AbstractJavaCodegen
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.delegatePattern && this.java8) {
|
||||
if ((!this.delegatePattern && this.java8) || this.delegateMethod) {
|
||||
additionalProperties.put("jdk8-no-delegate", true);
|
||||
}
|
||||
|
||||
|
||||
if (this.delegatePattern) {
|
||||
if (this.delegatePattern && !this.delegateMethod) {
|
||||
additionalProperties.put("isDelegate", "true");
|
||||
apiTemplateFiles.put("apiDelegate.mustache", "Delegate.java");
|
||||
}
|
||||
|
@ -100,7 +100,14 @@ public interface {{classname}} {
|
||||
produces = { {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }, {{/hasProduces}}{{#hasConsumes}}
|
||||
consumes = { {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} },{{/hasConsumes}}{{/singleContentTypes}}
|
||||
method = RequestMethod.{{httpMethod}})
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
{{#jdk8}}default {{/jdk8}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}){{^jdk8}};{{/jdk8}}{{#jdk8}} {
|
||||
{{#delegate-method}}
|
||||
return {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
}
|
||||
|
||||
// Override this method
|
||||
default {{#responseWrapper}}{{.}}<{{/responseWrapper}}ResponseEntity<{{>returnTypes}}>{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{{dataType}}}{{/isFile}}{{#isFile}}MultipartFile{{/isFile}} {{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
||||
{{/delegate-method}}
|
||||
{{^isDelegate}}
|
||||
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
|
||||
{{#examples}}
|
||||
@ -125,4 +132,4 @@ public interface {{classname}} {
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
{{/operations}}
|
Loading…
x
Reference in New Issue
Block a user