78 lines
2.5 KiB
Plaintext

package {{package}};
import com.wordnik.swagger.annotations.*;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import {{package}}.NotFoundException;
import javax.ws.rs.core.Response;
import javax.ws.rs.*;
@Path("/{{baseName}}.json")
@Api(value = "/{{baseName}}", description = "the {{baseName}} API")
@Produces({"application/json"})
public class {{className}} {
{{#operations}}
{{#operation}}
@{{httpMethod}}
@Path("{{path}}")
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", responseClass = "{{{returnType}}}")
@ApiErrors(value = { {{#errorList}} @ApiError(code = {{{code}}}, reason = "{{{reason}}}"){{#hasMore}},{{/hasMore}}
{{/errorList}}
})
public Response {{nickname}}(
{{#allParams}}
{{#queryParameter}}
@ApiParam(value = "{{{description}}}"
{{#required}},required=true{{newline}}{{/required}}
{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{newline}}{{/allowableValues}}
{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{newline}}{{/defaultValue}}
)@QueryParam("{{paramName}}"){{newline}} {{{dataType}}} {{paramName}}
{{/queryParameter}}
{{#pathParameter}}
@ApiParam(value = "{{{description}}}"
{{#required}},required=true{{newline}}{{/required}}
{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{newline}}{{/allowableValues}}
{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{newline}}{{/defaultValue}}
)@PathParam("{{paramName}}"){{newline}} {{{dataType}}} {{paramName}}
{{/pathParameter}}
{{#headerParameter}}
@ApiParam(value = "{{{description}}}"
{{#required}},required=true{{newline}}{{/required}}
{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{newline}}{{/allowableValues}}
{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{newline}}{{/defaultValue}}
)@HeaderParam("{{paramName}}"){{newline}} {{{dataType}}} {{paramName}}
{{/headerParameter}}
{{#bodyParameter}}
@ApiParam(value = "{{{description}}}"
{{#required}},required=true{{newline}}{{/required}}
{{#allowableValues}}, allowableValues="{{{allowableValues}}}"{{newline}}{{/allowableValues}}
{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{newline}}{{/defaultValue}}
) {{{dataType}}} {{paramName}}
{{/bodyParameter}}
{{#hasMore}},{{/hasMore}}
{{/allParams}}
)
throws NotFoundException {
// do some magic!
return Response.ok().entity(new ApiResponse(ApiResponse.OK, "magic!")).build();
}
{{/operation}}
{{/operations}}
}