forked from loafle/openapi-generator-original
committed by
wing328
parent
f00e6b349e
commit
bca35f6645
@@ -6,9 +6,9 @@ import java.util.Objects;
|
||||
{{#serializableModel}}
|
||||
import java.io.Serializable;
|
||||
{{/serializableModel}}
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
{{#useBeanValidation}}
|
||||
import javax.validation.constraints.*;
|
||||
import com.fasterxml.jackson.annotation.*;
|
||||
{{/useBeanValidation}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
|
||||
@@ -27,12 +27,12 @@ import swagger.SwaggerUtils.ApiAction;
|
||||
{{#operations}}
|
||||
public class {{classname}}Controller extends Controller {
|
||||
|
||||
private final {{classname}}ControllerImp imp;
|
||||
{{^controllerOnly}}private final {{classname}}ControllerImp imp;{{/controllerOnly}}
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
private {{classname}}Controller({{classname}}ControllerImp imp) {
|
||||
this.imp = imp;
|
||||
private {{classname}}Controller({{^controllerOnly}}{{classname}}ControllerImp imp{{/controllerOnly}}) {
|
||||
{{^controllerOnly}}this.imp = imp;{{/controllerOnly}}
|
||||
mapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
@@ -129,10 +129,12 @@ public class {{classname}}Controller extends Controller {
|
||||
}{{/required}}
|
||||
{{/collectionFormat}}
|
||||
{{/headerParams}}
|
||||
{{^controllerOnly}}
|
||||
{{#returnType}}{{>returnTypesNoVoid}} obj = {{/returnType}}imp.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{#returnType}}{{^isResponseFile}}JsonNode result = mapper.valueToTree(obj);
|
||||
return ok(result);{{/isResponseFile}}{{#isResponseFile}}return ok(obj);{{/isResponseFile}}{{/returnType}}
|
||||
{{^returnType}}return ok();{{/returnType}}
|
||||
{{^returnType}}return ok();{{/returnType}}{{/controllerOnly}}
|
||||
{{#controllerOnly}}return ok();{{/controllerOnly}}
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ import java.util.*;
|
||||
|
||||
public class SwaggerUtils {
|
||||
|
||||
{{#handleExceptions}}
|
||||
{{#wrapCalls}}
|
||||
@With(ApiCall.class)
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface ApiAction {
|
||||
}
|
||||
{{/handleExceptions}}
|
||||
{{/wrapCalls}}
|
||||
|
||||
public static List<String> parametersToList(String collectionFormat, String[] values){
|
||||
List<String> params = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user