@@ -77,48 +77,52 @@ Please follow the [installation](#installation) instruction and execute the foll
7777
7878```java
7979{ {#apiInfo} }{ {#apis} }{ {#-first} }{ {#operations} }{ {#operation} }{ {#-first} }
80- import { {{invokerPackage} }}.*;
81- import { {{invokerPackage} }}.auth.*;
82- import { {{modelPackage} }}.*;
80+ // Import classes:
81+ import { {{invokerPackage} }}.ApiClient;
82+ import { {{invokerPackage} }}.ApiException;
83+ import { {{invokerPackage} }}.Configuration;{ {#hasAuthMethods} }
84+ import { {{invokerPackage} }}.auth.*;{ {/hasAuthMethods} }
85+ import { {{invokerPackage} }}.models.*;
8386import { {{package} }}.{ {{classname} }};
8487
85- import java.io.File;
86- import java.util.*;
87-
88- public class { {{classname } }}Example {
89-
90- public static void main(String[] args) {
91- {{#hasAuthMethods } }ApiClient defaultClient = Configuration.getDefaultApiClient();
92- { {#authMethods } } { {#isBasic } }
93- // Configure HTTP basic authorization: { {{name} }}
94- HttpBasicAuth { {{name} }} = (HttpBasicAuth) defaultClient.getAuthentication(" { {{name } }}");
95- { {{name} }}.setUsername("YOUR USERNAME");
96- { {{name} }}.setPassword("YOUR PASSWORD"); { {/isBasic } } { {#isApiKey } }
97- // Configure API key authorization: { {{name} }}
98- ApiKeyAuth { {{name } }} = (ApiKeyAuth) defaultClient.getAuthentication(" { {{name } }}");
99- { {{name} }}.setApiKey("YOUR API KEY ");
100- // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
101- // { {{name} }}.setApiKeyPrefix("Token"); { {/isApiKey } } { {#isOAuth } }
102- // Configure OAuth2 access token for authorization: { {{name} }}
103- OAuth { {{name } }} = (OAuth) defaultClient.getAuthentication(" { {{name } }}");
104- { {{name } }}.setAccessToken("YOUR ACCESS TOKEN"); { {/isOAuth } }
105- { {/authMethods } }
106- { {/hasAuthMethods } }
107-
108- { {{classname } }} apiInstance = new { {{classname } }}();
109- { {# allParams} }
110- { {{dataType } }} { {{paramName } }} = { {{example } }}; // { {{dataType } }} | { {{description } }}
111- { {/allParams} }
112- try {
113- {{#returnType } } { {{returnType } }} result = { {/returnType } }apiInstance. { {{operationId } }} { {^vendorExtensions.x-group-parameters } }( { {#allParams } } { {{paramName } }} { {#hasMore } }, { {/hasMore } } { {/allParams } } );{ {/vendorExtensions.x-group-parameters} }{ {#vendorExtensions.x-group-parameters } }( { {#requiredParams } } { {{paramName } }} { {#hasMore } }, { {/hasMore } } { {/requiredParams } }) { {#optionalParams } }
114- . { {{paramName } }}( { {{paramName } }}) { {/optionalParams } }
115- .execute(); { {/vendorExtensions.x-group-parameters } } { {#returnType } }
116- System.out .println(result); { {/returnType } }
117- } catch (ApiException e) {
118- System.err.println(" Exception when calling {{{classname}}}#{{{operationId}}} " );
119- e.printStackTrace( );
120- }
88+ public class Example {
89+ public static void main(String[] args) {
90+ ApiClient defaultClient = Configuration.getDefaultApiClient();
91+ defaultClient.setBasePath( " {{{basePath }}}" );
92+ {{#hasAuthMethods } }
93+ { {#authMethods } } { {#isBasic } }
94+ // Configure HTTP basic authorization: { {{name } }}
95+ HttpBasicAuth { {{name } }} = (HttpBasicAuth) defaultClient.getAuthentication(" { {{name } }}");
96+ { {{name} }}.setUsername("YOUR USERNAME");
97+ { {{name} }}.setPassword("YOUR PASSWORD"); { {/isBasic } } { {#isApiKey } }
98+ // Configure API key authorization: { {{name} }}
99+ ApiKeyAuth { {{name} }} = (ApiKeyAuth) defaultClient.getAuthentication(" { {{name } }}");
100+ { {{name} }}.setApiKey("YOUR API KEY");
101+ // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
102+ // { {{name} }}.setApiKeyPrefix("Token ");{ {/isApiKey } } { {#isOAuth } }
103+ // Configure OAuth2 access token for authorization: { {{name } }}
104+ OAuth { {{name} }} = (OAuth) defaultClient.getAuthentication(" { {{name } }}");
105+ { {{name} }}.setAccessToken("YOUR ACCESS TOKEN"); { {/isOAuth } }
106+ { {/authMethods } }
107+ { {/hasAuthMethods } }
108+
109+ { {{classname } }} apiInstance = new { {{classname } }}(defaultClient);
110+ { {#allParams } }
111+ { {{dataType } }} { {{paramName } }} = { {{example } }}; // { {{dataType } }} | { {{description } }}
112+ { {/ allParams} }
113+ try {
114+ {{#returnType } } { {{returnType } }} result = { {/returnType } }apiInstance. { {{operationId } }} { {^vendorExtensions.x-group-parameters } }( { {# allParams} } { {{paramName } }} { {#hasMore } }, { {/hasMore } } { {/allParams } }); { {/vendorExtensions.x-group-parameters } } { {#vendorExtensions.x-group-parameters } }( { {#requiredParams } } { {{paramName } }} { {#hasMore } }, { {/hasMore } } { {/requiredParams } }) { {#optionalParams } }
115+ . { {{paramName } }}( { {{paramName } }}) { {/optionalParams } }
116+ .execute( );{ {/vendorExtensions.x-group-parameters} }{ {#returnType } }
117+ System.out.println(result); { {/returnType } }
118+ } catch (ApiException e) {
119+ System.err .println(" Exception when calling {{{classname}}}#{{{operationId}}} " );
120+ System.err.println( " Status code: " + e.getCode());
121+ System.err.println(" Reason: " + e.getResponseBody() );
122+ System.err.println( " Response headers: " + e.getResponseHeaders() );
123+ e.printStackTrace();
121124 }
125+ }
122126}
123127{ {/-first} }{ {/operation} }{ {/operations} }{ {/-first} }{ {/apis} }{ {/apiInfo} }
124128```
0 commit comments