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

handlebars.JavaJaxRS.resteasy.api.mustache Maven / Gradle / Ivy

There is a newer version: 1.0.54
Show newest version
package {{package}};

{{#hasModel}}import {{modelPackage}}.*;{{/hasModel}}
import {{package}}.{{classname}}Service;

{{#useOas2}}
import io.swagger.annotations.ApiParam;
import io.swagger.jaxrs.*;
{{/useOas2}}
{{^useOas2}}
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
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.security.SecurityRequirement;
{{/useOas2}}

{{#imports}}import {{import}};
{{/imports}}

import java.util.Map;
import java.util.List;
import {{package}}.NotFoundException;

import java.io.InputStream;

{{#jakarta}}
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.SecurityContext;
import jakarta.ws.rs.*;
import jakarta.inject.Inject;
{{/jakarta}}
{{^jakarta}}
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*;
import javax.inject.Inject;
{{/jakarta}}

{{#useBeanValidation}}
{{#jakarta}}
import jakarta.validation.constraints.*;
{{/jakarta}}
{{^jakarta}}
import javax.validation.constraints.*;
{{/jakarta}}
{{/useBeanValidation}}
{{#operations}}
{{#operation}}
{{#isMultipart}}
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
{{/isMultipart}}
{{/operation}}
{{/operations}}
@Path("/{{{baseName}}}")
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
{{#useOas2}}
@io.swagger.annotations.Api(description = "the {{{baseName}}} API")
{{/useOas2}}
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}}  {

    @Inject {{classname}}Service service;

{{#operation}}
{{#contents}}
    @{{httpMethod}}
    {{#subresourceOperation}}@Path("{{{path}}}"){{/subresourceOperation}}
    {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
    {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
    {{#useOas2}}
    @io.swagger.annotations.ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnBaseType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
        {{#authMethods}}@io.swagger.annotations.Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
            {{#each scopes}}@io.swagger.annotations.AuthorizationScope(scope = "{{@key}}", description = "{{this}}"){{^@last}},{{/@last}}
            {{/each}}
        }{{/isOAuth}}){{#hasMore}},{{/hasMore}}
        {{/authMethods}}
    }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}",{{/vendorExtensions.x-tags}} })
    @io.swagger.annotations.ApiResponses(value = {
        {{#responses}}
        @io.swagger.annotations.ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{baseType}}}.class{{#containerType}}, responseContainer = "{{{containerType}}}"{{/containerType}}){{#hasMore}},{{/hasMore}}
        {{/responses}} })
    {{/useOas2}}
    {{^useOas2}}
    @Operation(summary = "{{{summary}}}", description = "{{{notes}}}"{{#hasAuthMethods}}, security = {
        {{#authMethods}}@SecurityRequirement(name = "{{name}}"{{#isOAuth}}, scopes = {
            {{#each scopes}}"{{@key}}"{{^@last}},{{/@last}}
            {{/each}}
        }{{/isOAuth}}){{#hasMore}},{{/hasMore}}
        {{/authMethods}}
    }{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
    @ApiResponses(value = { {{#responses}}
        @ApiResponse(responseCode = "{{{code}}}", description = "{{{message}}}"{{^vendorExtensions.x-java-is-response-void}}, content = @Content({{#schema.extensions.x-content-type}}mediaType = "{{schema.extensions.x-content-type}}", {{/schema.extensions.x-content-type}}{{^containerType}}schema = @Schema(implementation = {{{baseType}}}.class)){{/containerType}}{{#containerType}}array = @ArraySchema(schema = @Schema(implementation = {{{baseType}}}.class))){{/containerType}}{{/vendorExtensions.x-java-is-response-void}}){{#hasMore}},
        {{/hasMore}}{{/responses}} })
    {{/useOas2}}
    public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#parameters}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{>cookieParams}}{{>comma}}{{/parameters}}@Context SecurityContext securityContext)
    throws NotFoundException {
        return service.{{nickname}}({{#isMultipart}}input,{{/isMultipart}}{{#parameters}}{{^isFormParam}}{{paramName}}{{/isFormParam}}{{#isFormParam}}{{^isBinary}}{{paramName}}{{/isBinary}}{{/isFormParam}}{{>comma}}{{/parameters}}securityContext);
    }
{{/contents}}
{{/operation}}
}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy