Skip to content

Commit

Permalink
Fixing the api-doc to generate more meaningful example.
Browse files Browse the repository at this point in the history
  • Loading branch information
elkezza committed Sep 12, 2024
1 parent 325ed49 commit b994868
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions generator/libraries/native/api_doc.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +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}}}.client.*;
import {{{invokerPackage}}}.*;
import {{{invokerPackage}}}.models.*;
import {{{package}}}.{{{classname}}};{{#vendorExtensions.x-group-parameters}}
import {{{package}}}.{{{classname}}}.*;{{/vendorExtensions.x-group-parameters}}
Expand All @@ -42,20 +39,37 @@ import java.util.concurrent.CompletableFuture;
{{/asyncNative}}

public class Example {
public static void main(String[] args) {
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<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}client.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});
{{/vendorExtensions.x-group-parameters}}
{{#vendorExtensions.x-group-parameters}}
{{#hasParams}}
API{{operationId}}Request request = API{{operationId}}Request.newBuilder(){{#allParams}}
.{{paramName}}({{paramName}}){{/allParams}}
.build();
{{/hasParams}}
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}apiInstance.{{operationId}}({{#hasParams}}request{{/hasParams}});
{{#returnType}}{{#asyncNative}}CompletableFuture<{{{returnType}}}>{{/asyncNative}}{{^asyncNative}}{{{returnType}}}{{/asyncNative}} result = {{/returnType}}{{^returnType}}{{#asyncNative}}CompletableFuture<Void> result = {{/asyncNative}}{{/returnType}}client.{{operationId}}({{#hasParams}}request{{/hasParams}});
{{/vendorExtensions.x-group-parameters}}
{{#returnType}}
System.out.println(result{{#asyncNative}}.get(){{/asyncNative}});
Expand Down

0 comments on commit b994868

Please sign in to comment.