From 777aa64f60dbd420ac1b578dfff070109e9a944b Mon Sep 17 00:00:00 2001 From: Panos Argyrakis Date: Tue, 26 Apr 2022 17:33:43 -0400 Subject: [PATCH 1/3] Added api getters --- .../libraries/okhttp-gson/ApiClient.mustache | 12 ++++ .../org/openapitools/client/ApiClient.java | 12 ++++ .../org/openapitools/client/ApiClient.java | 57 ++++++++++++++++ .../org/openapitools/client/ApiClient.java | 57 ++++++++++++++++ .../org/openapitools/client/ApiClient.java | 66 +++++++++++++++++++ 5 files changed, 204 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index 0bddc657e0d3..f3dee11d70c5 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -2,6 +2,7 @@ package {{invokerPackage}}; +import {{apiPackage}}.*; {{#dynamicOperations}} import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; @@ -1755,4 +1756,15 @@ public class ApiClient { // empty http request body return ""; } + + {{#apiInfo}}{{#apis}} + /** + * Get an instance of {{classname}} + * + * @return An instance of {{classname}} + */ + public {{classname}} {{classVarName}}Api() { + return new {{classname}}(this); + } + {{/apis}}{{/apiInfo}} } diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java index 20c24352d3d8..536ca6d54663 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java @@ -13,6 +13,7 @@ package org.openapitools.client; +import org.openapitools.client.api.*; import okhttp3.*; import okhttp3.internal.http.HttpMethod; import okhttp3.internal.tls.OkHostnameVerifier; @@ -1479,4 +1480,15 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException // empty http request body return ""; } + + + /** + * Get an instance of PingApi + * + * @return An instance of PingApi + */ + public PingApi pingApi() { + return new PingApi(this); + } + } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java index c065d7d109fe..2377d8d5808a 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java @@ -13,6 +13,7 @@ package org.openapitools.client; +import org.openapitools.client.api.*; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.PathItem; @@ -1626,4 +1627,60 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException // empty http request body return ""; } + + + /** + * Get an instance of AnotherFakeApi + * + * @return An instance of AnotherFakeApi + */ + public AnotherFakeApi anotherFakeApi() { + return new AnotherFakeApi(this); + } + + /** + * Get an instance of FakeApi + * + * @return An instance of FakeApi + */ + public FakeApi fakeApi() { + return new FakeApi(this); + } + + /** + * Get an instance of FakeClassnameTags123Api + * + * @return An instance of FakeClassnameTags123Api + */ + public FakeClassnameTags123Api fakeClassnameTags123Api() { + return new FakeClassnameTags123Api(this); + } + + /** + * Get an instance of PetApi + * + * @return An instance of PetApi + */ + public PetApi petApi() { + return new PetApi(this); + } + + /** + * Get an instance of StoreApi + * + * @return An instance of StoreApi + */ + public StoreApi storeApi() { + return new StoreApi(this); + } + + /** + * Get an instance of UserApi + * + * @return An instance of UserApi + */ + public UserApi userApi() { + return new UserApi(this); + } + } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java index 8ae5d16c3baf..f27da2ea39f8 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java @@ -13,6 +13,7 @@ package org.openapitools.client; +import org.openapitools.client.api.*; import okhttp3.*; import okhttp3.internal.http.HttpMethod; import okhttp3.internal.tls.OkHostnameVerifier; @@ -1558,4 +1559,60 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException // empty http request body return ""; } + + + /** + * Get an instance of AnotherFakeApi + * + * @return An instance of AnotherFakeApi + */ + public AnotherFakeApi anotherFakeApi() { + return new AnotherFakeApi(this); + } + + /** + * Get an instance of FakeApi + * + * @return An instance of FakeApi + */ + public FakeApi fakeApi() { + return new FakeApi(this); + } + + /** + * Get an instance of FakeClassnameTags123Api + * + * @return An instance of FakeClassnameTags123Api + */ + public FakeClassnameTags123Api fakeClassnameTags123Api() { + return new FakeClassnameTags123Api(this); + } + + /** + * Get an instance of PetApi + * + * @return An instance of PetApi + */ + public PetApi petApi() { + return new PetApi(this); + } + + /** + * Get an instance of StoreApi + * + * @return An instance of StoreApi + */ + public StoreApi storeApi() { + return new StoreApi(this); + } + + /** + * Get an instance of UserApi + * + * @return An instance of UserApi + */ + public UserApi userApi() { + return new UserApi(this); + } + } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java index 0e626694f6f9..ab124dbeb0c7 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java @@ -13,6 +13,7 @@ package org.openapitools.client; +import org.openapitools.client.api.*; import okhttp3.*; import okhttp3.internal.http.HttpMethod; import okhttp3.internal.tls.OkHostnameVerifier; @@ -1577,4 +1578,69 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException // empty http request body return ""; } + + + /** + * Get an instance of AnotherFakeApi + * + * @return An instance of AnotherFakeApi + */ + public AnotherFakeApi anotherFakeApi() { + return new AnotherFakeApi(this); + } + + /** + * Get an instance of DefaultApi + * + * @return An instance of DefaultApi + */ + public DefaultApi _defaultApi() { + return new DefaultApi(this); + } + + /** + * Get an instance of FakeApi + * + * @return An instance of FakeApi + */ + public FakeApi fakeApi() { + return new FakeApi(this); + } + + /** + * Get an instance of FakeClassnameTags123Api + * + * @return An instance of FakeClassnameTags123Api + */ + public FakeClassnameTags123Api fakeClassnameTags123Api() { + return new FakeClassnameTags123Api(this); + } + + /** + * Get an instance of PetApi + * + * @return An instance of PetApi + */ + public PetApi petApi() { + return new PetApi(this); + } + + /** + * Get an instance of StoreApi + * + * @return An instance of StoreApi + */ + public StoreApi storeApi() { + return new StoreApi(this); + } + + /** + * Get an instance of UserApi + * + * @return An instance of UserApi + */ + public UserApi userApi() { + return new UserApi(this); + } + } From 3a60a4769f51cf2213aa5d1ba632c777b1ab0252 Mon Sep 17 00:00:00 2001 From: Panos Argyrakis Date: Tue, 26 Apr 2022 17:56:58 -0400 Subject: [PATCH 2/3] updated naming --- .../Java/libraries/okhttp-gson/ApiClient.mustache | 2 +- .../java/org/openapitools/client/ApiClient.java | 2 +- .../java/org/openapitools/client/ApiClient.java | 12 ++++++------ .../java/org/openapitools/client/ApiClient.java | 12 ++++++------ .../java/org/openapitools/client/ApiClient.java | 14 +++++++------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index f3dee11d70c5..bf7bc02f9be6 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -1763,7 +1763,7 @@ public class ApiClient { * * @return An instance of {{classname}} */ - public {{classname}} {{classVarName}}Api() { + public {{classname}} get{{classname}}() { return new {{classname}}(this); } {{/apis}}{{/apiInfo}} diff --git a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java index 536ca6d54663..12b1304e8181 100644 --- a/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/others/java/okhttp-gson-streaming/src/main/java/org/openapitools/client/ApiClient.java @@ -1487,7 +1487,7 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException * * @return An instance of PingApi */ - public PingApi pingApi() { + public PingApi getPingApi() { return new PingApi(this); } diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java index 2377d8d5808a..62da5ef78d3f 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/src/main/java/org/openapitools/client/ApiClient.java @@ -1634,7 +1634,7 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException * * @return An instance of AnotherFakeApi */ - public AnotherFakeApi anotherFakeApi() { + public AnotherFakeApi getAnotherFakeApi() { return new AnotherFakeApi(this); } @@ -1643,7 +1643,7 @@ public AnotherFakeApi anotherFakeApi() { * * @return An instance of FakeApi */ - public FakeApi fakeApi() { + public FakeApi getFakeApi() { return new FakeApi(this); } @@ -1652,7 +1652,7 @@ public FakeApi fakeApi() { * * @return An instance of FakeClassnameTags123Api */ - public FakeClassnameTags123Api fakeClassnameTags123Api() { + public FakeClassnameTags123Api getFakeClassnameTags123Api() { return new FakeClassnameTags123Api(this); } @@ -1661,7 +1661,7 @@ public FakeClassnameTags123Api fakeClassnameTags123Api() { * * @return An instance of PetApi */ - public PetApi petApi() { + public PetApi getPetApi() { return new PetApi(this); } @@ -1670,7 +1670,7 @@ public PetApi petApi() { * * @return An instance of StoreApi */ - public StoreApi storeApi() { + public StoreApi getStoreApi() { return new StoreApi(this); } @@ -1679,7 +1679,7 @@ public StoreApi storeApi() { * * @return An instance of UserApi */ - public UserApi userApi() { + public UserApi getUserApi() { return new UserApi(this); } diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java index f27da2ea39f8..9b401c0d5c71 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/org/openapitools/client/ApiClient.java @@ -1566,7 +1566,7 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException * * @return An instance of AnotherFakeApi */ - public AnotherFakeApi anotherFakeApi() { + public AnotherFakeApi getAnotherFakeApi() { return new AnotherFakeApi(this); } @@ -1575,7 +1575,7 @@ public AnotherFakeApi anotherFakeApi() { * * @return An instance of FakeApi */ - public FakeApi fakeApi() { + public FakeApi getFakeApi() { return new FakeApi(this); } @@ -1584,7 +1584,7 @@ public FakeApi fakeApi() { * * @return An instance of FakeClassnameTags123Api */ - public FakeClassnameTags123Api fakeClassnameTags123Api() { + public FakeClassnameTags123Api getFakeClassnameTags123Api() { return new FakeClassnameTags123Api(this); } @@ -1593,7 +1593,7 @@ public FakeClassnameTags123Api fakeClassnameTags123Api() { * * @return An instance of PetApi */ - public PetApi petApi() { + public PetApi getPetApi() { return new PetApi(this); } @@ -1602,7 +1602,7 @@ public PetApi petApi() { * * @return An instance of StoreApi */ - public StoreApi storeApi() { + public StoreApi getStoreApi() { return new StoreApi(this); } @@ -1611,7 +1611,7 @@ public StoreApi storeApi() { * * @return An instance of UserApi */ - public UserApi userApi() { + public UserApi getUserApi() { return new UserApi(this); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java index ab124dbeb0c7..e1169839a80c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/org/openapitools/client/ApiClient.java @@ -1585,7 +1585,7 @@ private String requestBodyToString(RequestBody requestBody) throws ApiException * * @return An instance of AnotherFakeApi */ - public AnotherFakeApi anotherFakeApi() { + public AnotherFakeApi getAnotherFakeApi() { return new AnotherFakeApi(this); } @@ -1594,7 +1594,7 @@ public AnotherFakeApi anotherFakeApi() { * * @return An instance of DefaultApi */ - public DefaultApi _defaultApi() { + public DefaultApi getDefaultApi() { return new DefaultApi(this); } @@ -1603,7 +1603,7 @@ public DefaultApi _defaultApi() { * * @return An instance of FakeApi */ - public FakeApi fakeApi() { + public FakeApi getFakeApi() { return new FakeApi(this); } @@ -1612,7 +1612,7 @@ public FakeApi fakeApi() { * * @return An instance of FakeClassnameTags123Api */ - public FakeClassnameTags123Api fakeClassnameTags123Api() { + public FakeClassnameTags123Api getFakeClassnameTags123Api() { return new FakeClassnameTags123Api(this); } @@ -1621,7 +1621,7 @@ public FakeClassnameTags123Api fakeClassnameTags123Api() { * * @return An instance of PetApi */ - public PetApi petApi() { + public PetApi getPetApi() { return new PetApi(this); } @@ -1630,7 +1630,7 @@ public PetApi petApi() { * * @return An instance of StoreApi */ - public StoreApi storeApi() { + public StoreApi getStoreApi() { return new StoreApi(this); } @@ -1639,7 +1639,7 @@ public StoreApi storeApi() { * * @return An instance of UserApi */ - public UserApi userApi() { + public UserApi getUserApi() { return new UserApi(this); } From d385b8520317624a1545b7dd44b3267c0d9af805 Mon Sep 17 00:00:00 2001 From: Panos Argyrakis Date: Tue, 26 Apr 2022 18:07:54 -0400 Subject: [PATCH 3/3] updated README to use getter --- .../main/resources/Java/libraries/okhttp-gson/README.mustache | 2 +- samples/client/others/java/okhttp-gson-streaming/README.md | 2 +- .../petstore/java/okhttp-gson-dynamicOperations/README.md | 2 +- .../client/petstore/java/okhttp-gson-parcelableModel/README.md | 2 +- samples/client/petstore/java/okhttp-gson/README.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache index b4b5d2cdda60..596edf52a5fd 100644 --- a/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache +++ b/modules/openapi-generator/src/main/resources/Java/libraries/okhttp-gson/README.mustache @@ -116,7 +116,7 @@ public class Example { {{/authMethods}} {{/hasAuthMethods}} - {{{classname}}} apiInstance = new {{{classname}}}(defaultClient); + {{{classname}}} apiInstance = defaultClient.get{{{classname}}}(); {{#allParams}} {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} {{/allParams}} diff --git a/samples/client/others/java/okhttp-gson-streaming/README.md b/samples/client/others/java/okhttp-gson-streaming/README.md index ef1bda7072e2..f0fbd9834265 100644 --- a/samples/client/others/java/okhttp-gson-streaming/README.md +++ b/samples/client/others/java/okhttp-gson-streaming/README.md @@ -90,7 +90,7 @@ public class Example { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://localhost:8082"); - PingApi apiInstance = new PingApi(defaultClient); + PingApi apiInstance = defaultClient.getPingApi(); SomeObj someObj = new SomeObj(); // SomeObj | try { SomeObj result = apiInstance.postPing(someObj); diff --git a/samples/client/petstore/java/okhttp-gson-dynamicOperations/README.md b/samples/client/petstore/java/okhttp-gson-dynamicOperations/README.md index 054726451fd9..f9d0303c8649 100644 --- a/samples/client/petstore/java/okhttp-gson-dynamicOperations/README.md +++ b/samples/client/petstore/java/okhttp-gson-dynamicOperations/README.md @@ -90,7 +90,7 @@ public class Example { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); - AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient); + AnotherFakeApi apiInstance = defaultClient.getAnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.call123testSpecialTags(body); diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/README.md b/samples/client/petstore/java/okhttp-gson-parcelableModel/README.md index b3e111f6884e..41472d596e64 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/README.md +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/README.md @@ -90,7 +90,7 @@ public class Example { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); - AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient); + AnotherFakeApi apiInstance = defaultClient.getAnotherFakeApi(); Client body = new Client(); // Client | client model try { Client result = apiInstance.call123testSpecialTags(body); diff --git a/samples/client/petstore/java/okhttp-gson/README.md b/samples/client/petstore/java/okhttp-gson/README.md index d1dbd67d76e4..00a8550496c0 100644 --- a/samples/client/petstore/java/okhttp-gson/README.md +++ b/samples/client/petstore/java/okhttp-gson/README.md @@ -90,7 +90,7 @@ public class Example { ApiClient defaultClient = Configuration.getDefaultApiClient(); defaultClient.setBasePath("http://petstore.swagger.io:80/v2"); - AnotherFakeApi apiInstance = new AnotherFakeApi(defaultClient); + AnotherFakeApi apiInstance = defaultClient.getAnotherFakeApi(); Client client = new Client(); // Client | client model try { Client result = apiInstance.call123testSpecialTags(client);