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

templates.kotlin-micronaut.server.controller-interface.mustache Maven / Gradle / Ivy

{{>common/licenseInfo}}
package {{apiPackage}}
{{#formatNoEmptyLines}}
import io.micronaut.http.annotation.*
import io.micronaut.core.annotation.Nullable
import io.micronaut.core.convert.format.Format
{{#useAuth}}
import io.micronaut.security.annotation.Secured
import io.micronaut.security.rules.SecurityRule
{{/useAuth}}
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse
{{/wrapInHttpResponse}}
{{#imports}}
import {{import}}
{{/imports}}
{{#generatedAnnotation}}
import {{javaxPackage}}.annotation.Generated
{{/generatedAnnotation}}
{{#useBeanValidation}}
import {{javaxPackage}}.validation.Valid
import {{javaxPackage}}.validation.constraints.*
{{/useBeanValidation}}
{{#generateSwagger2Annotations}}
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.Parameters
import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.enums.ParameterIn
import io.swagger.v3.oas.annotations.tags.Tag
import io.swagger.v3.oas.annotations.security.SecurityRequirement
{{/generateSwagger2Annotations}}
{{/formatNoEmptyLines}}

{{#formatOneEmptyLine}}
{{#generatedAnnotation}}
{{>common/generatedAnnotation}}
{{/generatedAnnotation}}
{{^generateControllerAsAbstract}}
@Controller
{{/generateControllerAsAbstract}}
{{#generateSwagger2Annotations}}
@Tag(name = "{{{baseName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"The {{{baseName}}} API"{{/tagDescription}})
{{/generateSwagger2Annotations}}
interface {{classname}} {

{{#operations}}
    {{#operation}}
        {{#formatNoEmptyLines}}
{{>common/operationAnnotations}}
    @{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}("{{{path}}}")
    {{^vendorExtensions.onlyDefaultProduceOrEmpty}}
    @Produces({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}})
    {{/vendorExtensions.onlyDefaultProduceOrEmpty}}
    {{^vendorExtensions.onlyDefaultConsumeOrEmpty}}
    @Consumes({{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}})
    {{/vendorExtensions.onlyDefaultConsumeOrEmpty}}
    {{!security annotations}}
    {{#useAuth}}
    @Secured({{#vendorExtensions.x-roles}}{{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-roles}})
    {{/useAuth}}
    {{!the method definition}}
    {{#vendorExtensions.x-operation-extra-annotation}}
    {{{.}}}
    {{/vendorExtensions.x-operation-extra-annotation}}
    fun {{nickname}}({{#allParams}}
        {{#formatSingleLine}}{{>server/params/annotations}}{{#indent}}{{>common/params/validation}}{{/indent}}
        {{#vendorExtensions.formatPattern}}
            @Format("{{{.}}}")
        {{/vendorExtensions.formatPattern}}
        {{^vendorExtensions.formatPattern}}
            {{#isDateTime}}{{#dateTimeFormat}}@Format("{{{dateTimeFormat}}}"){{/dateTimeFormat}}{{/isDateTime}}
            {{#isDate}}{{#dateFormat}}@Format("{{{dateFormat}}}"){{/dateFormat}}{{/isDate}}
        {{/vendorExtensions.formatPattern}}
        {{#isDeprecated}}
            @java.lang.Deprecated
        {{/isDeprecated}}
 {{{paramName}}}: {{#isEnum}}{{{vendorExtensions.typeWithEnumWithGenericAnnotations}}}{{/isEnum}}{{^isEnum}}{{{vendorExtensions.typeWithGenericAnnotations}}}{{/isEnum}}{{^-last}},{{/-last}}{{/formatSingleLine}}
    {{/allParams}}){{#returnType}}: {{{returnType}}}{{/returnType}}
        {{/formatNoEmptyLines}}

    {{/operation}}
{{/operations}}
}
{{/formatOneEmptyLine}}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy