github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/openapi-generator/templates/java/README.mustache (about)

     1  # {{artifactId}}
     2  
     3  {{appName}}
     4  
     5  - API version: {{appVersion}}
     6  - Package version: {{artifactVersion}}
     7  
     8  Phrase Strings is a translation management platform for software projects. You can collaborate on language file translation with your team or order translations through our platform. The API allows you to import locale files, download locale files, tag keys or interact in other ways with the localization data stored in Phrase Strings for your account.
     9  
    10  {{#infoUrl}}
    11    For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
    12  {{/infoUrl}}
    13  
    14  *Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*
    15  
    16  ## Requirements
    17  
    18  Building the API client library requires:
    19  
    20  1. Java {{#supportJava6}}1.6{{/supportJava6}}{{^supportJava6}}{{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}{{/supportJava6}}+
    21  2. Maven/Gradle
    22  
    23  ## Installation
    24  
    25  ### Maven users
    26  
    27  Add this dependency to your project's POM:
    28  
    29  ```xml
    30  <dependency>
    31    <groupId>{{{groupId}}}</groupId>
    32    <artifactId>{{{artifactId}}}</artifactId>
    33    <version>{{{artifactVersion}}}</version>
    34    <scope>compile</scope>
    35  </dependency>
    36  ```
    37  
    38  ### Gradle users
    39  
    40  Add this dependency to your project's build file:
    41  
    42  ```groovy
    43  compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}"
    44  ```
    45  
    46  ### Others
    47  
    48  At first generate the JAR by executing:
    49  
    50  ```shell
    51  mvn clean package
    52  ```
    53  
    54  Then manually install the following JARs:
    55  
    56  - `target/{{{artifactId}}}-{{{artifactVersion}}}.jar`
    57  - `target/lib/*.jar`
    58  
    59  ### Github package repository
    60  
    61  Currently the packages are also automatically deployed to Github package repository, so that you don't need
    62  to build them yourself. Follow [this guide](https://docs.github.com/en/packages/working-with-a-github-packages-registry)
    63  to set it up in your project.
    64  
    65  ## Getting Started
    66  
    67  Please follow the [installation](#installation) instruction and execute the following Java code:
    68  
    69  ```java
    70  {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
    71  import {{{invokerPackage}}}.*;
    72  import {{{invokerPackage}}}.auth.*;
    73  import {{{modelPackage}}}.*;
    74  import {{{package}}}.{{{classname}}};
    75  
    76  public class {{{classname}}}Example {
    77  
    78      public static void main(String[] args) {
    79          ApiClient defaultClient = Configuration.getDefaultApiClient();
    80          defaultClient.setBasePath("{{{basePath}}}");
    81          {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}}
    82          // Configure HTTP basic authorization: {{{name}}}
    83          HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}");
    84          {{{name}}}.setUsername("YOUR USERNAME");
    85          {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasicBasic}}{{#isBasicBearer}}
    86          // Configure HTTP bearer authorization: {{{name}}}
    87          HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}");
    88          {{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}}
    89          // Configure API key authorization: {{{name}}}
    90          ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}");
    91          {{{name}}}.setApiKey("YOUR API KEY");
    92          {{{name}}}.setApiKeyPrefix("token");{{/isApiKey}}{{#isOAuth}}
    93          // Configure OAuth2 access token for authorization: {{{name}}}
    94          OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}");
    95          {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}}
    96          {{/authMethods}}
    97          {{/hasAuthMethods}}
    98  
    99          {{{classname}}} apiInstance = new {{{classname}}}(defaultClient);
   100          {{#allParams}}
   101          {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
   102          {{/allParams}}
   103          try {
   104              {{#returnType}}{{{returnType}}} result = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}}
   105              System.out.println(result);{{/returnType}}
   106          } catch (ApiException e) {
   107              System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}");
   108              System.err.println("Status code: " + e.getCode());
   109              System.err.println("Reason: " + e.getResponseBody());
   110              System.err.println("Response headers: " + e.getResponseHeaders());
   111              e.printStackTrace();
   112          }
   113      }
   114  }
   115  {{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
   116  ```
   117  
   118  ## Documentation for API Endpoints
   119  
   120  All URIs are relative to *{{basePath}}*
   121  
   122  Class | Method | HTTP request | Description
   123  ------------ | ------------- | ------------- | -------------
   124  {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
   125  {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
   126  
   127  ## Documentation for Models
   128  
   129  {{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md)
   130  {{/model}}{{/models}}
   131  
   132  ## Documentation for Authorization
   133  
   134  {{^authMethods}}All endpoints do not require authorization.
   135  {{/authMethods}}Authentication schemes defined for the API:
   136  {{#authMethods}}### {{name}}
   137  
   138  {{#isApiKey}}
   139  
   140  - **Type**: API key
   141  - **API key parameter name**: {{keyParamName}}
   142  - **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
   143  {{/isApiKey}}
   144  {{#isBasic}}
   145  
   146  - **Type**: HTTP basic authentication
   147  {{/isBasic}}
   148  {{#isOAuth}}
   149  
   150  - **Type**: OAuth
   151  - **Flow**: {{flow}}
   152  - **Authorization URL**: {{authorizationUrl}}
   153  - **Scopes**: {{^scopes}}N/A{{/scopes}}
   154  {{#scopes}}  - {{scope}}: {{description}}
   155  {{/scopes}}
   156  {{/isOAuth}}
   157  
   158  {{/authMethods}}
   159  
   160  ## Recommendation
   161  
   162  It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues.
   163  
   164  ## Author
   165  
   166  {{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
   167  {{/-last}}{{/apis}}{{/apiInfo}}
   168  
   169  ## Get help / support
   170  
   171  Please contact [support@phrase.com](mailto:support@phrase.com?subject=[GitHub]%20phrase-java) and we can take more direct action toward finding a solution.