diff --git a/generator/libraries/native/api_doc.mustache b/generator/libraries/native/api_doc.mustache index c521e7f39..81da7937f 100644 --- a/generator/libraries/native/api_doc.mustache +++ b/generator/libraries/native/api_doc.mustache @@ -29,10 +29,8 @@ All URIs are relative to *{{basePath}}* ```java // Import classes: -import {{{invokerPackage}}}.ApiClient; import {{{invokerPackage}}}.ApiException; -import {{{invokerPackage}}}.Configuration;{{#hasAuthMethods}} -import {{{invokerPackage}}}.auth.*;{{/hasAuthMethods}} +import {{{invokerPackage}}}.*; import {{{invokerPackage}}}.models.*; import {{{package}}}.{{{classname}}};{{#vendorExtensions.x-group-parameters}} import {{{package}}}.{{{classname}}}.*;{{/vendorExtensions.x-group-parameters}} @@ -41,36 +39,29 @@ import java.util.concurrent.CompletableFuture; {{/asyncNative}} public class Example { - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - defaultClient.setBasePath("{{{basePath}}}"); - {{#hasAuthMethods}} - {{#authMethods}}{{#isBasic}}{{#isBasicBasic}} - // Configure HTTP basic authorization: {{{name}}} - HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setUsername("YOUR USERNAME"); - {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasicBasic}}{{#isBasicBearer}} - // Configure HTTP bearer authorization: {{{name}}} - HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} - // Configure API key authorization: {{{name}}} - ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setApiKey("YOUR API KEY"); - // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) - //{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} - // Configure OAuth2 access token for authorization: {{{name}}} - OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); - {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}} - {{/authMethods}} - {{/hasAuthMethods}} - - {{{classname}}} apiInstance = new {{{classname}}}(defaultClient); + public static void main(String[] args) throws ApiException, InterruptedException{ + // Initialize the client with credentials + Client client = new Client(new Credentials(System.getenv("EXOSCALE_API_KEY"), System.getenv("EXOSCALE_API_SECRET"))); {{#allParams}} + {{^isString}} + {{^isUuid}} + {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} please add at least all the required fields + {{/isUuid}} + {{/isString}} + {{^isUuid}} + {{#isString}} {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} + {{/isString}} + {{/isUuid}} + {{#isUuid}} + {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} + {{/isUuid}} {{/allParams}} + try { + // Invoke the API method {{^vendorExtensions.x-group-parameters}} - {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture result = {{/asyncNative}}{{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}); + {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture result = {{/asyncNative}}{{/returnType}}client.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}); {{/vendorExtensions.x-group-parameters}} {{#vendorExtensions.x-group-parameters}} {{#hasParams}} @@ -78,7 +69,7 @@ public class Example { .{{paramName}}({{paramName}}){{/allParams}} .build(); {{/hasParams}} - {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture result = {{/asyncNative}}{{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}}); + {{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture result = {{/asyncNative}}{{/returnType}}client.{{operationId}}({{#hasParams}}request{{/hasParams}}); {{/vendorExtensions.x-group-parameters}} {{#returnType}} System.out.println(result{{#asyncNative}}.get(){{/asyncNative}});