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

jersey2-v3template.Impl.mustache Maven / Gradle / Ivy

Go to download

jersey2 generator from openapi 3.x spec files. Changing to openapitools dependencies.

There is a newer version: 6.6
Show newest version
{{>licenseInfo}}

package {{package}}.impl;

import cd.connect.openapi.support.ApiClient;
import cd.connect.openapi.support.ApiResponse;
import {{package}}.{{classname}};
import {{package}}.{{classname}}Client;
import cd.connect.openapi.support.Pair;
import javax.ws.rs.BadRequestException;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import javax.ws.rs.*;
import javax.validation.constraints.*;
import javax.validation.Valid;

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

{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}

{{>generatedAnnotation}}
{{#operations}}
public class {{classname}}ServiceImpl implements {{classname}}, {{classname}}Client {
  private ApiClient {{localVariablePrefix}}apiClient;

  public {{classname}}ServiceImpl(ApiClient apiClient) {
    this.{{localVariablePrefix}}apiClient = apiClient;
  }

  public ApiClient getApiClient() {
    return {{localVariablePrefix}}apiClient;
  }

  public void setApiClient(ApiClient apiClient) {
    this.{{localVariablePrefix}}apiClient = apiClient;
  }

  {{#operation}}
  /**
  * {{summary}}
  * {{notes}}
  {{#allParams}}
    * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
  {{/allParams}}
  {{#returnType}}
    * @return {{returnType}}
  {{/returnType}}
  {{#isDeprecated}}
    * @deprecated
  {{/isDeprecated}}
  {{#externalDocs}}
    * {{description}}
    * @see {{summary}} Documentation
  {{/externalDocs}}
  */
  {{#isDeprecated}}
    @Deprecated
  {{/isDeprecated}}
  public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}Response {{/returnType}}{{operationId}}({{#allParams}}{{>serviceQueryParams}}{{>pathParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
  {{#returnType}}
    {{^vendorExtensions.x-java-is-response-void}}return {{/vendorExtensions.x-java-is-response-void}}
     {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
    {{^vendorExtensions.x-java-is-response-void}}.getData(){{/vendorExtensions.x-java-is-response-void}}
    ;
  {{/returnType}}{{^returnType}}
    {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
  {{/returnType}}
  }

  /**
  * {{summary}}
  * {{notes}}
  {{#allParams}}
    * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
  {{/allParams}}
  {{#returnType}}
    * @return {{returnType}}
  {{/returnType}}
  {{#isDeprecated}}
    * @deprecated
  {{/isDeprecated}}
  {{#externalDocs}}
    * {{description}}
    * @see {{summary}} Documentation
  {{/externalDocs}}
  */
  {{#isDeprecated}}
    @Deprecated
  {{/isDeprecated}}
  public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}Response {{/returnType}}{{operationId}}({{#allParams}}{{>serviceQueryParams}}{{>pathParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Map extraHeaders) {
  {{#returnType}}
    {{^vendorExtensions.x-java-is-response-void}}return {{/vendorExtensions.x-java-is-response-void}}
    {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}extraHeaders)
    {{^vendorExtensions.x-java-is-response-void}}.getData(){{/vendorExtensions.x-java-is-response-void}}
    ;
  {{/returnType}}{{^returnType}}
    {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}extraHeaders);
  {{/returnType}}
  }

  /**
  * {{summary}}
  * {{notes}}
  {{#allParams}}
    * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
  {{/allParams}}
  {{#returnType}}
    * @return ApiResponse<{{#vendorExtensions.x-java-is-response-void}}Void{{/vendorExtensions.x-java-is-response-void}}{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}}{{/vendorExtensions.x-java-is-response-void}}>
  {{/returnType}}
  {{#isDeprecated}}
    * @deprecated
  {{/isDeprecated}}
  {{#externalDocs}}
    * {{description}}
    * @see {{summary}} Documentation
  {{/externalDocs}}
  */
  {{#isDeprecated}}
    @Deprecated
  {{/isDeprecated}}
  public ApiResponse<{{#vendorExtensions.x-java-is-response-void}}Void{{/vendorExtensions.x-java-is-response-void}}{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}}{{/vendorExtensions.x-java-is-response-void}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
  {{#returnType}}
      return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}null);
  {{/returnType}}{{^returnType}}
    {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}null);
  {{/returnType}}

  }

    /**
   * {{summary}}
   * {{notes}}
   {{#allParams}}
   * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}
   {{/allParams}}
   {{#returnType}}
   * @return ApiResponse<{{#vendorExtensions.x-java-is-response-void}}Void{{/vendorExtensions.x-java-is-response-void}}{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}}{{/vendorExtensions.x-java-is-response-void}}>
   {{/returnType}}
   {{#isDeprecated}}
   * @deprecated
   {{/isDeprecated}}
   {{#externalDocs}}
   * {{description}}
   * @see {{summary}} Documentation
   {{/externalDocs}}
   */
  {{#isDeprecated}}
  @Deprecated
  {{/isDeprecated}}
  public ApiResponse<{{#vendorExtensions.x-java-is-response-void}}Void{{/vendorExtensions.x-java-is-response-void}}{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}}{{/vendorExtensions.x-java-is-response-void}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Map extraHeaders) {
    Object {{localVariablePrefix}}localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}new Object(){{/bodyParam}};
    {{#allParams}}{{#required}}
    // verify the required parameter '{{paramName}}' is set
    if ({{paramName}} == null) {
      throw new BadRequestException("Missing the required parameter '{{paramName}}' when calling {{operationId}}");
    }
    {{/required}}{{/allParams}}
    // create path and map variables {{{baseName}}}{{{path}}}
    String {{localVariablePrefix}}localVarPath = "{{{baseName}}}{{{path}}}"{{#pathParams}}
      .replaceAll("\\{" + "{{baseName}}" + "\\}", {{localVariablePrefix}}apiClient.escapeString({{{paramName}}}.toString())){{/pathParams}};

    // query params
    {{javaUtilPrefix}}List {{localVariablePrefix}}localVarQueryParams = new {{javaUtilPrefix}}ArrayList();
    {{javaUtilPrefix}}Map {{localVariablePrefix}}localVarHeaderParams = new {{javaUtilPrefix}}HashMap();
    {{javaUtilPrefix}}Map {{localVariablePrefix}}localVarFormParams = new {{javaUtilPrefix}}HashMap();

    if (extraHeaders != null) {
      localVarHeaderParams.putAll(extraHeaders);
    }

    {{#queryParams}}
    {{localVariablePrefix}}localVarQueryParams.addAll({{localVariablePrefix}}apiClient.parameterToPairs("{{#collectionFormat}}{{{collectionFormat}}}{{/collectionFormat}}", "{{baseName}}", {{paramName}}));
    {{/queryParams}}

    {{#headerParams}}if ({{paramName}} != null)
      {{localVariablePrefix}}localVarHeaderParams.put("{{baseName}}", {{localVariablePrefix}}apiClient.parameterToString({{paramName}}));
    {{/headerParams}}

    {{#formParams}}if ({{paramName}} != null)
      {{localVariablePrefix}}localVarFormParams.put("{{baseName}}", {{paramName}});
    {{/formParams}}

    final String[] {{localVariablePrefix}}localVarAccepts = {
      {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
    };
    final String {{localVariablePrefix}}localVarAccept = {{localVariablePrefix}}apiClient.selectHeaderAccept({{localVariablePrefix}}localVarAccepts);

    final String[] {{localVariablePrefix}}localVarContentTypes = {
      {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
    };
    final String {{localVariablePrefix}}localVarContentType = {{localVariablePrefix}}apiClient.selectHeaderContentType({{localVariablePrefix}}localVarContentTypes);

    String[] {{localVariablePrefix}}localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };

    {{#returnType}}
    GenericType<{{#vendorExtensions.x-java-is-response-void}}Void{{/vendorExtensions.x-java-is-response-void}}{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}}{{/vendorExtensions.x-java-is-response-void}}> {{localVariablePrefix}}localVarReturnType = new GenericType<{{#vendorExtensions.x-java-is-response-void}}Void{{/vendorExtensions.x-java-is-response-void}}{{^vendorExtensions.x-java-is-response-void}}{{{returnType}}}{{/vendorExtensions.x-java-is-response-void}}>() {};
    return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccept, {{localVariablePrefix}}localVarContentType, {{localVariablePrefix}}localVarAuthNames, {{localVariablePrefix}}localVarReturnType);
    {{/returnType}}{{^returnType}}
    return {{localVariablePrefix}}apiClient.invokeAPI({{localVariablePrefix}}localVarPath, "{{httpMethod}}", {{localVariablePrefix}}localVarQueryParams, {{localVariablePrefix}}localVarPostBody, {{localVariablePrefix}}localVarHeaderParams, {{localVariablePrefix}}localVarFormParams, {{localVariablePrefix}}localVarAccept, {{localVariablePrefix}}localVarContentType, {{localVariablePrefix}}localVarAuthNames, null);
    {{/returnType}}
  }
  {{/operation}}
}
{{/operations}}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy