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

com.github.upachler.swagger.codegen.jaxrslean.templates.api.mustache Maven / Gradle / Ivy

The newest version!
package {{package}};

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

import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;

import java.net.URI;
import java.util.List;

/**
 * The {{baseName}} API
 */
@Path("/{{baseName}}"){{#hasConsumes}}
@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}}
@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
{{>generatedAnnotation}}
public interface {{classname}}  {
{{#operations}}
{{#operation}}

    /**
     * {{summary}}.
     * {{notes}}
     * {{#hasAuthMethods}}Authentication:
* {{#authMethods}}"{{name}}"{{#isOAuth}}
* scopes:
*
    * {{#scopes}}
  • {{scope}}: {{description}}")
  • {{#hasMore}} * {{/hasMore}} * {{/scopes}}
* {{/isOAuth}}){{#hasMore}}, * {{/hasMore}}{{/authMethods}} * {{/hasAuthMethods}} * {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}}
*
    {{#responses}}
  • {{{code}}}: {{{message}}}
  • * {{/responses}}
* {{#allParams}}@param {{paramName}} {{baseName}} parameter. {{description}} * {{/allParams}} * {{^vendorExtensions.x-jax-rs-return-type-void}} * {{#returnType}}@return {{returnType}}{{/returnType}} * {{/vendorExtensions.x-jax-rs-return-type-void}} */ @{{httpMethod}}{{#subresourceOperation}} @Path("{{path}}"){{/subresourceOperation}}{{#hasConsumes}} @Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}{{#hasProduces}} @Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} public {{>actualReturnType}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}); {{/operation}} {{#operation}} /** * Generates a URI with the path and query components set so that they refer * to the {{path}} subresource. Note that the application base and context paths * will be missing and need to be prefixed. * {{^pathParams.isEmpty}}Path templates are expanded to match given path parameters{{/pathParams.isEmpty}} * {{^queryParams.isEmpty}}Query params are appended to reflect the passed query parameters{{/queryParams.isEmpty}} * {{#pathParams}}@param {{paramName}} The {{baseName}} path parameter * {{/pathParams}}{{#queryParams}}@param {{paramName}} The {{baseName}} query parameter * {{/queryParams}} * @return A URI to the {{path}} subresource */ public static URI {{nickname}}URI({{#pathParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/pathParams}}{{^pathParams.isEmpty}}{{^queryParams.isEmpty}}, {{/queryParams.isEmpty}}{{/pathParams.isEmpty}}{{#queryParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/queryParams}}) { UriBuilder b = UriBuilder.fromResource({{classname}}.class) .path("{{path}}") {{#pathParams}}.resolveTemplate("{{baseName}}", {{paramName}}) {{/pathParams}}; {{#queryParams}}if({{paramName}}!=null) { if(java.util.Collection.class.isAssignableFrom({{paramName}}.getClass())) { java.util.Collection c = java.util.Collection.class.cast({{paramName}}); b.queryParam("{{baseName}}", c.toArray(new Object[c.size()])); } else { b.queryParam("{{baseName}}", {{paramName}}); } }{{/queryParams}}; return b.build(); } {{/operation}} } {{/operations}}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy