All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kotlin-spring.api.mustache Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
package {{package}}

{{#imports}}import {{import}}
{{/imports}}
{{#swaggerAnnotations}}
import io.swagger.annotations.*
{{/swaggerAnnotations}}
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestMapping
{{#useBeanValidation}}
import org.springframework.validation.annotation.Validated
{{/useBeanValidation}}
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired

{{#useBeanValidation}}
import javax.validation.Valid
import javax.validation.constraints.*
{{/useBeanValidation}}

import kotlin.collections.List
import kotlin.collections.Map

@Controller
{{#useBeanValidation}}
@Validated
{{/useBeanValidation}}
{{#swaggerAnnotations}}
@Api(value = "{{{baseName}}}", description = "The {{{baseName}}} API")
{{/swaggerAnnotations}}
{{=<% %>=}}
@RequestMapping("\${api.base-path:<%contextPath%>}")
<%={{ }}=%>
{{#operations}}
class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) val service: {{classname}}Service{{/serviceInterface}}) {
{{#operation}}

    {{#swaggerAnnotations}}
    @ApiOperation(
            value = "{{{summary}}}",
            nickname = "{{{operationId}}}",
            notes = "{{{notes}}}"{{#returnBaseType}},
            response = {{{returnBaseType}}}::class{{/returnBaseType}}{{#returnContainer}},
            responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}},
            authorizations = [{{#authMethods}}Authorization(value = "{{name}}"{{#isOAuth}}, scopes = [{{#scopes}}AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, {{/hasMore}}{{/scopes}}]{{/isOAuth}}){{#hasMore}}, {{/hasMore}}{{/authMethods}}]{{/hasAuthMethods}})
    @ApiResponses(
            value = [{{#responses}}ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{#baseType}}, response = {{{baseType}}}::class{{/baseType}}{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}{{/responses}}]){{/swaggerAnnotations}}
    @RequestMapping(
            value = ["{{#lambda.escapeDoubleQuote}}{{path}}{{/lambda.escapeDoubleQuote}}"],{{#singleContentTypes}}{{#hasProduces}}
            produces = "{{{vendorExtensions.x-accepts}}}", {{/hasProduces}}{{#hasConsumes}}
            consumes = "{{{vendorExtensions.x-contentType}}}",{{/hasConsumes}}{{/singleContentTypes}}{{^singleContentTypes}}{{#hasProduces}}
            produces = [{{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}], {{/hasProduces}}{{#hasConsumes}}
            consumes = [{{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}],{{/hasConsumes}}{{/singleContentTypes}}
            method = [RequestMethod.{{httpMethod}}])
    fun {{operationId}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}): ResponseEntity<{{>returnTypes}}> {
        return {{>returnValue}}
    }
{{/operation}}
}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy