java-micronaut.server.controller.mustache Maven / Gradle / Ivy
{{>common/licenseInfo}}
package {{apiPackage}};
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}}
{{#reactive}}
import reactor.core.publisher.Mono;
{{/reactive}}
{{#wrapInHttpResponse}}
import io.micronaut.http.HttpResponse;
{{/wrapInHttpResponse}}
{{#generateOperationsToReturnNotImplemented}}
import io.micronaut.http.HttpStatus;
import io.micronaut.http.exceptions.HttpStatusException;
{{/generateOperationsToReturnNotImplemented}}
{{#imports}}
import {{import}};
{{/imports}}
import {{javaxPackage}}.annotation.Generated;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{#generateControllerFromExamples}}
import java.util.Arrays;
{{/generateControllerFromExamples}}
{{#useBeanValidation}}
import {{javaxPackage}}.validation.Valid;
import {{javaxPackage}}.validation.constraints.*;
{{/useBeanValidation}}
{{#generateSwagger1Annotations}}
import io.swagger.annotations.*;
{{/generateSwagger1Annotations}}
{{#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.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
{{/generateSwagger2Annotations}}
{{>common/generatedAnnotation}}
{{^generateControllerAsAbstract}}
@Controller
{{/generateControllerAsAbstract}}
{{#generateSwagger2Annotations}}
@Tag(name = "{{{baseName}}}", description = {{#tagDescription}}"{{{.}}}"{{/tagDescription}}{{^tagDescription}}"The {{{baseName}}} API"{{/tagDescription}})
{{/generateSwagger2Annotations}}
public {{#generateControllerAsAbstract}}abstract {{/generateControllerAsAbstract}}class {{classname}} {
{{#operations}}
{{#operation}}
{{>common/operationAnnotations}}{{!
micronaut annotations
}} @{{#lambda.pascalcase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.pascalcase}}(uri="{{{path}}}")
@Produces(value = {{openbrace}}{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}{{closebrace}})
{{#consumes.0}}
@Consumes(value = {{openbrace}}{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}{{closebrace}})
{{/consumes.0}}
{{!security annotations}}
{{#useAuth}}
@Secured({{openbrace}}{{#vendorExtensions.x-roles}}{{{.}}}{{^-last}}, {{/-last}}{{/vendorExtensions.x-roles}}{{closebrace}})
{{/useAuth}}
{{!the method definition}}
public {{>common/operationReturnType}} {{nickname}}{{#generateControllerAsAbstract}}Api{{/generateControllerAsAbstract}}({{#allParams}}
{{>server/params/queryParams}}{{>server/params/pathParams}}{{>server/params/headerParams}}{{>server/params/bodyParams}}{{>server/params/formParams}}{{>server/params/cookieParams}}{{^-last}}, {{/-last}}{{#-last}}
{{/-last}}{{/allParams}}) {
{{^generateControllerAsAbstract}}
{{>server/controllerOperationBody}} }
{{/generateControllerAsAbstract}}
{{#generateControllerAsAbstract}}
return {{nickname}}({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
}
{{/generateControllerAsAbstract}}
{{#generateControllerAsAbstract}}
/**
{{#summary}}
* {{summary}}
{{/summary}}
*
* This method will be delegated to when the controller gets a request
*/
public {{^generateOperationsToReturnNotImplemented}}abstract {{/generateOperationsToReturnNotImplemented}}{{>common/operationReturnType}} {{nickname}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){{^generateOperationsToReturnNotImplemented}};{{/generateOperationsToReturnNotImplemented}}{{#generateOperationsToReturnNotImplemented}} {{openbrace}}
{{>server/controllerOperationBody}}
{{closebrace}}{{/generateOperationsToReturnNotImplemented}}{{/generateControllerAsAbstract}}
{{^-last}}
{{/-last}}
{{/operation}}
{{/operations}}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy