apiDelegate.mustache 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package {{package}};
  2. {{#imports}}import {{import}};
  3. {{/imports}}
  4. import org.springframework.http.HttpStatus;
  5. import org.springframework.http.MediaType;
  6. {{#useResponseEntity}}
  7. import org.springframework.http.ResponseEntity;
  8. {{/useResponseEntity}}
  9. import org.springframework.web.context.request.NativeWebRequest;
  10. import org.springframework.web.multipart.MultipartFile;
  11. {{#reactive}}
  12. import org.springframework.web.server.ServerWebExchange;
  13. import reactor.core.publisher.Flux;
  14. import reactor.core.publisher.Mono;
  15. import org.springframework.http.codec.multipart.Part;
  16. {{/reactive}}
  17. {{#useBeanValidation}}
  18. import {{javaxPackage}}.validation.constraints.*;
  19. import {{javaxPackage}}.validation.Valid;
  20. {{/useBeanValidation}}
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.Optional;
  24. {{#async}}
  25. import java.util.concurrent.CompletableFuture;
  26. {{/async}}
  27. import {{javaxPackage}}.annotation.Generated;
  28. import com.crunii.micro.common.dto.Result;
  29. import com.crunii.micro.common.dto.PageReq;
  30. import com.crunii.micro.common.dto.PageRsp;
  31. {{#operations}}
  32. /**
  33. * A delegate to be called by the {@link {{classname}}Controller}}.
  34. * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
  35. */
  36. {{>generatedAnnotation}}
  37. public interface {{classname}}Delegate {
  38. {{#jdk8-default-interface}}
  39. default Optional<NativeWebRequest> getRequest() {
  40. return Optional.empty();
  41. }
  42. {{/jdk8-default-interface}}
  43. {{#operation}}
  44. /**
  45. * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
  46. {{#notes}}
  47. * {{.}}
  48. {{/notes}}
  49. *
  50. {{#allParams}}
  51. * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
  52. {{/allParams}}
  53. * @return {{#responses}}{{message}} (status code {{code}}){{^-last}}
  54. * or {{/-last}}{{/responses}}
  55. {{#isDeprecated}}
  56. * @deprecated
  57. {{/isDeprecated}}
  58. {{#externalDocs}}
  59. * {{description}}
  60. * @see <a href="{{url}}">{{summary}} Documentation</a>
  61. {{/externalDocs}}
  62. * @see {{classname}}#{{operationId}}
  63. */
  64. {{#isDeprecated}}
  65. @Deprecated
  66. {{/isDeprecated}}
  67. {{#jdk8-default-interface}}default {{/jdk8-default-interface}}{{#responseWrapper}}{{.}}<{{/responseWrapper}}{{#useResponseEntity}}Result<{{/useResponseEntity}}{{^vendorExtensions.x-spring-paginated}}{{>returnTypes}}{{/vendorExtensions.x-spring-paginated}}{{#vendorExtensions.x-spring-paginated}}PageRsp<{{>returnTypes}}>{{/vendorExtensions.x-spring-paginated}}{{#useResponseEntity}}>{{/useResponseEntity}}{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{^vendorExtensions.x-spring-paginated}}{{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isArray}}List<{{/isArray}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}}{{/isFile}} {{paramName}}{{^-last}},
  68. {{/-last}}{{/allParams}}{{/vendorExtensions.x-spring-paginated}}{{#vendorExtensions.x-spring-paginated}}{{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}PageReq<{{{dataType}}}>{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#isArray}}List<{{/isArray}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{#isArray}}>{{/isArray}}{{/isFile}} {{paramName}}{{^-last}},
  69. {{/-last}}{{/allParams}}{{/vendorExtensions.x-spring-paginated}}{{#reactive}}{{#hasParams}},
  70. {{/hasParams}}ServerWebExchange exchange{{/reactive}}){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} {
  71. {{>methodBody}}
  72. }{{/jdk8-default-interface}}
  73. {{/operation}}
  74. }
  75. {{/operations}}