api.mustache 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. /**
  2. * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}).
  3. * https://openapi-generator.tech
  4. * Do not edit the class manually.
  5. */
  6. package {{package}};
  7. {{#imports}}import {{import}};
  8. {{/imports}}
  9. {{#swagger2AnnotationLibrary}}
  10. import io.swagger.v3.oas.annotations.ExternalDocumentation;
  11. import io.swagger.v3.oas.annotations.Operation;
  12. import io.swagger.v3.oas.annotations.Parameter;
  13. import io.swagger.v3.oas.annotations.Parameters;
  14. import io.swagger.v3.oas.annotations.media.ArraySchema;
  15. import io.swagger.v3.oas.annotations.media.Content;
  16. import io.swagger.v3.oas.annotations.media.Schema;
  17. import io.swagger.v3.oas.annotations.responses.ApiResponse;
  18. import io.swagger.v3.oas.annotations.security.SecurityRequirement;
  19. import io.swagger.v3.oas.annotations.tags.Tag;
  20. import io.swagger.v3.oas.annotations.enums.ParameterIn;
  21. {{/swagger2AnnotationLibrary}}
  22. {{#swagger1AnnotationLibrary}}
  23. import io.swagger.annotations.*;
  24. {{/swagger1AnnotationLibrary}}
  25. {{#jdk8-no-delegate}}
  26. {{#virtualService}}
  27. import io.virtualan.annotation.ApiVirtual;
  28. import io.virtualan.annotation.VirtualService;
  29. {{/virtualService}}
  30. import org.springframework.http.HttpStatus;
  31. import org.springframework.http.MediaType;
  32. {{/jdk8-no-delegate}}
  33. {{^useResponseEntity}}
  34. import org.springframework.http.HttpStatus;
  35. {{/useResponseEntity}}
  36. {{#useResponseEntity}}
  37. import org.springframework.http.ResponseEntity;
  38. {{/useResponseEntity}}
  39. {{#useBeanValidation}}
  40. import org.springframework.validation.annotation.Validated;
  41. {{/useBeanValidation}}
  42. {{#useSpringController}}
  43. {{#useResponseEntity}}
  44. import org.springframework.stereotype.Controller;
  45. {{/useResponseEntity}}
  46. {{^useResponseEntity}}
  47. import org.springframework.web.bind.annotation.RestController;
  48. {{/useResponseEntity}}
  49. {{/useSpringController}}
  50. import org.springframework.web.bind.annotation.*;
  51. {{#jdk8-no-delegate}}
  52. {{^reactive}}
  53. import org.springframework.web.context.request.NativeWebRequest;
  54. {{/reactive}}
  55. {{/jdk8-no-delegate}}
  56. import org.springframework.web.multipart.MultipartFile;
  57. {{#reactive}}
  58. import org.springframework.web.server.ServerWebExchange;
  59. import reactor.core.publisher.Flux;
  60. import reactor.core.publisher.Mono;
  61. import org.springframework.http.codec.multipart.Part;
  62. {{/reactive}}
  63. {{#useBeanValidation}}
  64. import {{javaxPackage}}.validation.Valid;
  65. import {{javaxPackage}}.validation.constraints.*;
  66. {{/useBeanValidation}}
  67. import java.util.List;
  68. import java.util.Map;
  69. {{#jdk8-no-delegate}}
  70. import java.util.Optional;
  71. {{/jdk8-no-delegate}}
  72. {{^jdk8-no-delegate}}
  73. {{#useOptional}}
  74. import java.util.Optional;
  75. {{/useOptional}}
  76. {{/jdk8-no-delegate}}
  77. {{#async}}
  78. import java.util.concurrent.CompletableFuture;
  79. {{/async}}
  80. import {{javaxPackage}}.annotation.Generated;
  81. import com.crunii.micro.common.dto.Result;
  82. import com.crunii.micro.common.dto.PageReq;
  83. import com.crunii.micro.common.dto.PageRsp;
  84. {{>generatedAnnotation}}
  85. {{#useBeanValidation}}
  86. @Validated
  87. {{/useBeanValidation}}
  88. {{#useSpringController}}
  89. {{#useResponseEntity}}
  90. @Controller
  91. {{/useResponseEntity}}
  92. {{^useResponseEntity}}
  93. @RestController
  94. {{/useResponseEntity}}
  95. {{/useSpringController}}
  96. {{#swagger2AnnotationLibrary}}
  97. @Tag(name = "{{{tagName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{tagName}}} API"{{/tagDescription}})
  98. {{/swagger2AnnotationLibrary}}
  99. {{#swagger1AnnotationLibrary}}
  100. @Api(value = "{{{tagName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"the {{{tagName}}} API"{{/tagDescription}})
  101. {{/swagger1AnnotationLibrary}}
  102. {{#operations}}
  103. {{#virtualService}}
  104. @VirtualService
  105. {{/virtualService}}
  106. {{#useRequestMappingOnInterface}}
  107. {{=<% %>=}}
  108. @RequestMapping("${openapi.<%title%>.base-path:<%>defaultBasePath%>}")
  109. <%={{ }}=%>
  110. {{/useRequestMappingOnInterface}}
  111. public interface {{classname}} {
  112. {{#jdk8-default-interface}}
  113. {{^isDelegate}}
  114. {{^reactive}}
  115. default Optional<NativeWebRequest> getRequest() {
  116. return Optional.empty();
  117. }
  118. {{/reactive}}
  119. {{/isDelegate}}
  120. {{#isDelegate}}
  121. default {{classname}}Delegate getDelegate() {
  122. return new {{classname}}Delegate() {};
  123. }
  124. {{/isDelegate}}
  125. {{/jdk8-default-interface}}
  126. {{#operation}}
  127. /**
  128. * {{httpMethod}} {{{path}}}{{#summary}} : {{.}}{{/summary}}
  129. {{#notes}}
  130. * {{.}}
  131. {{/notes}}
  132. *
  133. {{#allParams}}
  134. * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
  135. {{/allParams}}
  136. * @return {{#responses}}{{message}} (status code {{code}}){{^-last}}
  137. * or {{/-last}}{{/responses}}
  138. {{#isDeprecated}}
  139. * @deprecated
  140. {{/isDeprecated}}
  141. {{#externalDocs}}
  142. * {{description}}
  143. * @see <a href="{{url}}">{{summary}} Documentation</a>
  144. {{/externalDocs}}
  145. */
  146. {{#isDeprecated}}
  147. @Deprecated
  148. {{/isDeprecated}}
  149. {{#virtualService}}
  150. @ApiVirtual
  151. {{/virtualService}}
  152. {{#swagger2AnnotationLibrary}}
  153. @Operation(
  154. operationId = "{{{operationId}}}",
  155. {{#summary}}
  156. summary = "{{{.}}}",
  157. {{/summary}}
  158. {{#notes}}
  159. description = "{{{.}}}",
  160. {{/notes}}
  161. {{#vendorExtensions.x-tags.size}}
  162. tags = { {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} },
  163. {{/vendorExtensions.x-tags.size}}
  164. responses = {
  165. {{#responses}}
  166. @ApiResponse(responseCode = {{#isDefault}}"default"{{/isDefault}}{{^isDefault}}"{{{code}}}"{{/isDefault}}, description = "{{{message}}}"{{#baseType}}, content = {
  167. {{#produces}}
  168. @Content(mediaType = "{{{mediaType}}}", {{#isArray}}array = @ArraySchema({{/isArray}}schema = @Schema(implementation = {{{baseType}}}.class){{#isArray}}){{/isArray}}){{^-last}},{{/-last}}
  169. {{/produces}}
  170. }{{/baseType}}){{^-last}},{{/-last}}
  171. {{/responses}}
  172. }{{#hasAuthMethods}},
  173. security = {
  174. {{#authMethods}}
  175. @SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes={ {{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}} }{{/isOAuth}}){{^-last}},{{/-last}}
  176. {{/authMethods}}
  177. }{{/hasAuthMethods}}{{#externalDocs}},
  178. externalDocs = @ExternalDocumentation(description = "{{externalDocs.description}}", url = "{{externalDocs.url}}"){{/externalDocs}}
  179. )
  180. {{/swagger2AnnotationLibrary}}
  181. {{#swagger1AnnotationLibrary}}
  182. @ApiOperation(
  183. {{#vendorExtensions.x-tags.size}}
  184. tags = { {{#vendorExtensions.x-tags}}"{{tag}}"{{^-last}}, {{/-last}}{{/vendorExtensions.x-tags}} },
  185. {{/vendorExtensions.x-tags.size}}
  186. value = "{{{summary}}}",
  187. nickname = "{{{operationId}}}",
  188. notes = "{{{notes}}}"{{#returnBaseType}},
  189. response = {{{.}}}.class{{/returnBaseType}}{{#returnContainer}},
  190. responseContainer = "{{{.}}}"{{/returnContainer}}{{#hasAuthMethods}},
  191. authorizations = {
  192. {{#authMethods}}
  193. {{#isOAuth}}
  194. @Authorization(value = "{{name}}", scopes = {
  195. {{#scopes}}
  196. @AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{^-last}},{{/-last}}
  197. {{/scopes}}
  198. }){{^-last}},{{/-last}}
  199. {{/isOAuth}}
  200. {{^isOAuth}}
  201. @Authorization(value = "{{name}}"){{^-last}},{{/-last}}
  202. {{/isOAuth}}
  203. {{/authMethods}} }{{/hasAuthMethods}}
  204. )
  205. @ApiResponses({
  206. {{#responses}}
  207. @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{.}}}.class{{/baseType}}{{#containerType}}, responseContainer = "{{{.}}}"{{/containerType}}){{^-last}},{{/-last}}
  208. {{/responses}}
  209. })
  210. {{/swagger1AnnotationLibrary}}
  211. {{#implicitHeadersParams.0}}
  212. {{#swagger2AnnotationLibrary}}
  213. @Parameters({
  214. {{#implicitHeadersParams}}
  215. {{>paramDoc}}{{^-last}},{{/-last}}
  216. {{/implicitHeadersParams}}
  217. })
  218. {{/swagger2AnnotationLibrary}}
  219. {{#swagger1AnnotationLibrary}}
  220. @ApiImplicitParams({
  221. {{#implicitHeadersParams}}
  222. {{>implicitHeader}}{{^-last}},{{/-last}}
  223. {{/implicitHeadersParams}}
  224. })
  225. {{/swagger1AnnotationLibrary}}
  226. {{/implicitHeadersParams.0}}
  227. @RequestMapping(
  228. method = RequestMethod.{{httpMethod}},
  229. value = "{{{path}}}"{{#singleContentTypes}}{{#hasProduces}},
  230. produces = "{{{vendorExtensions.x-accepts}}}"{{/hasProduces}}{{#hasConsumes}},
  231. consumes = "{{{vendorExtensions.x-content-type}}}"{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}},
  232. produces = { {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }{{/hasProduces}}{{#hasConsumes}},
  233. consumes = { {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} }{{/hasConsumes}}{{/singleContentTypes}}{{#hasVersionHeaders}},
  234. headers = { {{#vendorExtensions.versionHeaderParamsList}}"{{baseName}}{{#defaultValue}}={{{.}}}{{/defaultValue}}"{{^-last}}, {{/-last}}{{/vendorExtensions.versionHeaderParamsList}} } {{/hasVersionHeaders}}{{#hasVersionQueryParams}},
  235. params = { {{#vendorExtensions.versionQueryParamsList}}"{{baseName}}{{#defaultValue}}={{{.}}}{{/defaultValue}}"{{^-last}}, {{/-last}}{{/vendorExtensions.versionQueryParamsList}} } {{/hasVersionQueryParams}}
  236. )
  237. {{^useResponseEntity}}
  238. @ResponseStatus({{#springHttpStatus}}{{#responses.0}}{{{code}}}{{/responses.0}}{{/springHttpStatus}})
  239. {{/useResponseEntity}}
  240. {{#vendorExtensions.x-operation-extra-annotation}}
  241. {{{.}}}
  242. {{/vendorExtensions.x-operation-extra-annotation}}
  243. {{#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}} {{#delegate-method}}_{{/delegate-method}}{{operationId}}(
  244. {{^vendorExtensions.x-spring-paginated}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
  245. {{/-last}}{{/allParams}}{{/vendorExtensions.x-spring-paginated}}{{#vendorExtensions.x-spring-paginated}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>pageBodyParams}}{{>formParams}}{{>cookieParams}}{{^-last}},
  246. {{/-last}}{{/allParams}}{{/vendorExtensions.x-spring-paginated}}{{#reactive}}{{#hasParams}},
  247. {{/hasParams}}{{#swagger2AnnotationLibrary}}@Parameter(hidden = true){{/swagger2AnnotationLibrary}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}
  248. ){{#unhandledException}} throws Exception{{/unhandledException}}{{^jdk8-default-interface}};{{/jdk8-default-interface}}{{#jdk8-default-interface}} {
  249. {{#delegate-method}}
  250. {{^isVoid}}return {{/isVoid}}{{#isVoid}}{{#useResponseEntity}}return {{/useResponseEntity}}{{^useResponseEntity}}{{#reactive}}return {{/reactive}}{{/useResponseEntity}}{{/isVoid}}{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}});
  251. }
  252. // Override this method
  253. {{#jdk8-default-interface}}default {{/jdk8-default-interface}} {{#responseWrapper}}{{.}}<{{/responseWrapper}}{{#useResponseEntity}}Result<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}}{{#responseWrapper}}>{{/responseWrapper}} {{operationId}}({{#allParams}}{{^isFile}}{{^isBodyParam}}{{>optionalDataType}}{{/isBodyParam}}{{#isBodyParam}}{{^reactive}}{{{dataType}}}{{/reactive}}{{#reactive}}{{^isArray}}Mono<{{{dataType}}}>{{/isArray}}{{#isArray}}Flux<{{{baseType}}}>{{/isArray}}{{/reactive}}{{/isBodyParam}}{{/isFile}}{{#isFile}}{{#reactive}}Flux<Part>{{/reactive}}{{^reactive}}MultipartFile{{/reactive}}{{/isFile}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}} final ServerWebExchange exchange{{/reactive}}{{#vendorExtensions.x-spring-paginated}}{{#hasParams}}, {{/hasParams}}{{^hasParams}}{{#reactive}}, {{/reactive}}{{/hasParams}}{{#springFoxDocumentationProvider}}@ApiIgnore{{/springFoxDocumentationProvider}}final Pageable pageable{{/vendorExtensions.x-spring-paginated}}){{#unhandledException}} throws Exception{{/unhandledException}} {
  254. {{/delegate-method}}
  255. {{^isDelegate}}
  256. {{>methodBody}}
  257. {{/isDelegate}}
  258. {{#isDelegate}}
  259. {{^isVoid}}return {{/isVoid}}{{#isVoid}}{{#useResponseEntity}}return {{/useResponseEntity}}{{^useResponseEntity}}{{#reactive}}return {{/reactive}}{{/useResponseEntity}}{{/isVoid}}getDelegate().{{operationId}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#reactive}}{{#hasParams}}, {{/hasParams}}exchange{{/reactive}});
  260. {{/isDelegate}}
  261. }{{/jdk8-default-interface}}
  262. {{/operation}}
  263. }
  264. {{/operations}}