From 5bac98cd9957a957e9b12bcb46b534f8cedd3370 Mon Sep 17 00:00:00 2001 From: Go Shibata Date: Tue, 20 Oct 2020 10:55:49 +0900 Subject: [PATCH] [kotlin][jvm-retrofit2] Update templates (#7592) * Fix indent of return tag * Trim trailing whitespace * Update samples Co-authored-by: Jim Schubert --- .../libraries/jvm-retrofit2/api.mustache | 6 +++--- .../infrastructure/ApiClient.kt.mustache | 20 +++++++++---------- .../org/openapitools/client/apis/PetApi.kt | 16 +++++++-------- .../org/openapitools/client/apis/StoreApi.kt | 8 ++++---- .../org/openapitools/client/apis/UserApi.kt | 16 +++++++-------- .../client/infrastructure/ApiClient.kt | 10 +++++----- .../org/openapitools/client/apis/PetApi.kt | 16 +++++++-------- .../org/openapitools/client/apis/StoreApi.kt | 8 ++++---- .../org/openapitools/client/apis/UserApi.kt | 16 +++++++-------- .../client/infrastructure/ApiClient.kt | 10 +++++----- 10 files changed, 63 insertions(+), 63 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache index 5bb18f913f1..18de2f19e03 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/api.mustache @@ -55,10 +55,10 @@ interface {{classname}} { * Responses:{{#responses}} * - {{code}}: {{{message}}}{{/responses}} * - {{#allParams}} + {{#allParams}} * @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} - {{/allParams}} - * @return {{^useCoroutines}}[Call]<{{/useCoroutines}}{{#isResponseFile}}[ResponseBody]{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}[{{{returnType}}}]{{/returnType}}{{^returnType}}[Unit]{{/returnType}}{{/isResponseFile}}{{^useCoroutines}}>{{/useCoroutines}} + {{/allParams}} + * @return {{^useCoroutines}}[Call]<{{/useCoroutines}}{{#isResponseFile}}[ResponseBody]{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}[{{{returnType}}}]{{/returnType}}{{^returnType}}[Unit]{{/returnType}}{{/isResponseFile}}{{^useCoroutines}}>{{/useCoroutines}} */ {{#isDeprecated}} @Deprecated("This api was deprecated") diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache index d556f0e9869..7d1e0ab806d 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/jvm-retrofit2/infrastructure/ApiClient.kt.mustache @@ -117,8 +117,8 @@ import retrofit2.converter.moshi.MoshiConverterFactory baseUrl: String = defaultBasePath, okHttpClientBuilder: OkHttpClient.Builder? = null, serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder, - authName: String, - username: String, + authName: String, + username: String, password: String ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { setCredentials(username, password) @@ -130,7 +130,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory baseUrl: String = defaultBasePath, okHttpClientBuilder: OkHttpClient.Builder? = null, serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder, - authName: String, + authName: String, bearerToken: String ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { setBearerToken(bearerToken) @@ -144,10 +144,10 @@ import retrofit2.converter.moshi.MoshiConverterFactory baseUrl: String = defaultBasePath, okHttpClientBuilder: OkHttpClient.Builder? = null, serializerBuilder: {{#gson}}Gson{{/gson}}{{#moshi}}Moshi.{{/moshi}}Builder = Serializer.{{#gson}}gson{{/gson}}{{#moshi}}moshi{{/moshi}}Builder, - authName: String, - clientId: String, - secret: String, - username: String, + authName: String, + clientId: String, + secret: String, + username: String, password: String ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { getTokenEndPoint() @@ -169,7 +169,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory apiAuthorizations.values.runOnFirst { tokenRequestBuilder.setUsername(username).setPassword(password) } - {{/hasOAuthMethods}} + {{/hasOAuthMethods}} return this } @@ -182,7 +182,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory } return this } - {{/hasOAuthMethods}} + {{/hasOAuthMethods}} {{/isBasicBasic}} {{#isBasicBearer}} fun setBearerToken(bearerToken: String): ApiClient { @@ -306,7 +306,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory } } - companion object { + companion object { @JvmStatic val defaultBasePath: String by lazy { System.getProperties().getProperty("{{packageName}}.baseUrl", "{{{basePath}}}") diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index b52cebf4c31..90e791f37af 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -19,7 +19,7 @@ interface PetApi { * - 405: Invalid input * * @param body Pet object that needs to be added to the store - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("pet") fun addPet(@Body body: Pet): Completable @@ -32,7 +32,7 @@ interface PetApi { * * @param petId Pet id to delete * @param apiKey (optional) - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @DELETE("pet/{petId}") fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Completable @@ -45,7 +45,7 @@ interface PetApi { * - 400: Invalid status value * * @param status Status values that need to be considered for filter - * @return [Call]<[kotlin.collections.List]> + * @return [Call]<[kotlin.collections.List]> */ @GET("pet/findByStatus") fun findPetsByStatus(@Query("status") status: CSVParams): Single> @@ -58,7 +58,7 @@ interface PetApi { * - 400: Invalid tag value * * @param tags Tags to filter by - * @return [Call]<[kotlin.collections.List]> + * @return [Call]<[kotlin.collections.List]> */ @Deprecated("This api was deprecated") @GET("pet/findByTags") @@ -73,7 +73,7 @@ interface PetApi { * - 404: Pet not found * * @param petId ID of pet to return - * @return [Call]<[Pet]> + * @return [Call]<[Pet]> */ @GET("pet/{petId}") fun getPetById(@Path("petId") petId: kotlin.Long): Single @@ -87,7 +87,7 @@ interface PetApi { * - 405: Validation exception * * @param body Pet object that needs to be added to the store - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @PUT("pet") fun updatePet(@Body body: Pet): Completable @@ -101,7 +101,7 @@ interface PetApi { * @param petId ID of pet that needs to be updated * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @FormUrlEncoded @POST("pet/{petId}") @@ -116,7 +116,7 @@ interface PetApi { * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return [Call]<[ApiResponse]> + * @return [Call]<[ApiResponse]> */ @Multipart @POST("pet/{petId}/uploadImage") diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 96603a0729a..11acb2eb8b7 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -17,7 +17,7 @@ interface StoreApi { * - 404: Order not found * * @param orderId ID of the order that needs to be deleted - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @DELETE("store/order/{orderId}") fun deleteOrder(@Path("orderId") orderId: kotlin.String): Completable @@ -28,7 +28,7 @@ interface StoreApi { * Responses: * - 200: successful operation * - * @return [Call]<[kotlin.collections.Map]> + * @return [Call]<[kotlin.collections.Map]> */ @GET("store/inventory") fun getInventory(): Single> @@ -42,7 +42,7 @@ interface StoreApi { * - 404: Order not found * * @param orderId ID of pet that needs to be fetched - * @return [Call]<[Order]> + * @return [Call]<[Order]> */ @GET("store/order/{orderId}") fun getOrderById(@Path("orderId") orderId: kotlin.Long): Single @@ -55,7 +55,7 @@ interface StoreApi { * - 400: Invalid Order * * @param body order placed for purchasing the pet - * @return [Call]<[Order]> + * @return [Call]<[Order]> */ @POST("store/order") fun placeOrder(@Body body: Order): Single diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 4e04bc3627e..d6fad78e88f 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -16,7 +16,7 @@ interface UserApi { * - 0: successful operation * * @param body Created user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("user") fun createUser(@Body body: User): Completable @@ -28,7 +28,7 @@ interface UserApi { * - 0: successful operation * * @param body List of user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("user/createWithArray") fun createUsersWithArrayInput(@Body body: kotlin.collections.List): Completable @@ -40,7 +40,7 @@ interface UserApi { * - 0: successful operation * * @param body List of user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("user/createWithList") fun createUsersWithListInput(@Body body: kotlin.collections.List): Completable @@ -53,7 +53,7 @@ interface UserApi { * - 404: User not found * * @param username The name that needs to be deleted - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @DELETE("user/{username}") fun deleteUser(@Path("username") username: kotlin.String): Completable @@ -67,7 +67,7 @@ interface UserApi { * - 404: User not found * * @param username The name that needs to be fetched. Use user1 for testing. - * @return [Call]<[User]> + * @return [Call]<[User]> */ @GET("user/{username}") fun getUserByName(@Path("username") username: kotlin.String): Single @@ -81,7 +81,7 @@ interface UserApi { * * @param username The user name for login * @param password The password for login in clear text - * @return [Call]<[kotlin.String]> + * @return [Call]<[kotlin.String]> */ @GET("user/login") fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Single @@ -92,7 +92,7 @@ interface UserApi { * Responses: * - 0: successful operation * - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @GET("user/logout") fun logoutUser(): Completable @@ -106,7 +106,7 @@ interface UserApi { * * @param username name that need to be deleted * @param body Updated user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @PUT("user/{username}") fun updateUser(@Path("username") username: kotlin.String, @Body body: User): Completable diff --git a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index f23b3308a41..30f649932fc 100644 --- a/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-retrofit2-rx3/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -73,10 +73,10 @@ class ApiClient( baseUrl: String = defaultBasePath, okHttpClientBuilder: OkHttpClient.Builder? = null, serializerBuilder: Moshi.Builder = Serializer.moshiBuilder, - authName: String, - clientId: String, - secret: String, - username: String, + authName: String, + clientId: String, + secret: String, + username: String, password: String ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { getTokenEndPoint() @@ -194,7 +194,7 @@ class ApiClient( } } - companion object { + companion object { @JvmStatic val defaultBasePath: String by lazy { System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2") diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/PetApi.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/PetApi.kt index 4d78248129c..e8b980bc872 100644 --- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/PetApi.kt +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/PetApi.kt @@ -18,7 +18,7 @@ interface PetApi { * - 405: Invalid input * * @param body Pet object that needs to be added to the store - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("pet") fun addPet(@Body body: Pet): Call @@ -31,7 +31,7 @@ interface PetApi { * * @param petId Pet id to delete * @param apiKey (optional) - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @DELETE("pet/{petId}") fun deletePet(@Path("petId") petId: kotlin.Long, @Header("api_key") apiKey: kotlin.String): Call @@ -44,7 +44,7 @@ interface PetApi { * - 400: Invalid status value * * @param status Status values that need to be considered for filter - * @return [Call]<[kotlin.collections.List]> + * @return [Call]<[kotlin.collections.List]> */ @GET("pet/findByStatus") fun findPetsByStatus(@Query("status") status: CSVParams): Call> @@ -57,7 +57,7 @@ interface PetApi { * - 400: Invalid tag value * * @param tags Tags to filter by - * @return [Call]<[kotlin.collections.List]> + * @return [Call]<[kotlin.collections.List]> */ @Deprecated("This api was deprecated") @GET("pet/findByTags") @@ -72,7 +72,7 @@ interface PetApi { * - 404: Pet not found * * @param petId ID of pet to return - * @return [Call]<[Pet]> + * @return [Call]<[Pet]> */ @GET("pet/{petId}") fun getPetById(@Path("petId") petId: kotlin.Long): Call @@ -86,7 +86,7 @@ interface PetApi { * - 405: Validation exception * * @param body Pet object that needs to be added to the store - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @PUT("pet") fun updatePet(@Body body: Pet): Call @@ -100,7 +100,7 @@ interface PetApi { * @param petId ID of pet that needs to be updated * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @FormUrlEncoded @POST("pet/{petId}") @@ -115,7 +115,7 @@ interface PetApi { * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) - * @return [Call]<[ApiResponse]> + * @return [Call]<[ApiResponse]> */ @Multipart @POST("pet/{petId}/uploadImage") diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt index 45b6d20b1c7..be05f2bb696 100644 --- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/StoreApi.kt @@ -16,7 +16,7 @@ interface StoreApi { * - 404: Order not found * * @param orderId ID of the order that needs to be deleted - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @DELETE("store/order/{orderId}") fun deleteOrder(@Path("orderId") orderId: kotlin.String): Call @@ -27,7 +27,7 @@ interface StoreApi { * Responses: * - 200: successful operation * - * @return [Call]<[kotlin.collections.Map]> + * @return [Call]<[kotlin.collections.Map]> */ @GET("store/inventory") fun getInventory(): Call> @@ -41,7 +41,7 @@ interface StoreApi { * - 404: Order not found * * @param orderId ID of pet that needs to be fetched - * @return [Call]<[Order]> + * @return [Call]<[Order]> */ @GET("store/order/{orderId}") fun getOrderById(@Path("orderId") orderId: kotlin.Long): Call @@ -54,7 +54,7 @@ interface StoreApi { * - 400: Invalid Order * * @param body order placed for purchasing the pet - * @return [Call]<[Order]> + * @return [Call]<[Order]> */ @POST("store/order") fun placeOrder(@Body body: Order): Call diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/UserApi.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/UserApi.kt index 33f031ec714..66c1e7fbd26 100644 --- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/UserApi.kt +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/apis/UserApi.kt @@ -15,7 +15,7 @@ interface UserApi { * - 0: successful operation * * @param body Created user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("user") fun createUser(@Body body: User): Call @@ -27,7 +27,7 @@ interface UserApi { * - 0: successful operation * * @param body List of user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("user/createWithArray") fun createUsersWithArrayInput(@Body body: kotlin.collections.List): Call @@ -39,7 +39,7 @@ interface UserApi { * - 0: successful operation * * @param body List of user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @POST("user/createWithList") fun createUsersWithListInput(@Body body: kotlin.collections.List): Call @@ -52,7 +52,7 @@ interface UserApi { * - 404: User not found * * @param username The name that needs to be deleted - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @DELETE("user/{username}") fun deleteUser(@Path("username") username: kotlin.String): Call @@ -66,7 +66,7 @@ interface UserApi { * - 404: User not found * * @param username The name that needs to be fetched. Use user1 for testing. - * @return [Call]<[User]> + * @return [Call]<[User]> */ @GET("user/{username}") fun getUserByName(@Path("username") username: kotlin.String): Call @@ -80,7 +80,7 @@ interface UserApi { * * @param username The user name for login * @param password The password for login in clear text - * @return [Call]<[kotlin.String]> + * @return [Call]<[kotlin.String]> */ @GET("user/login") fun loginUser(@Query("username") username: kotlin.String, @Query("password") password: kotlin.String): Call @@ -91,7 +91,7 @@ interface UserApi { * Responses: * - 0: successful operation * - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @GET("user/logout") fun logoutUser(): Call @@ -105,7 +105,7 @@ interface UserApi { * * @param username name that need to be deleted * @param body Updated user object - * @return [Call]<[Unit]> + * @return [Call]<[Unit]> */ @PUT("user/{username}") fun updateUser(@Path("username") username: kotlin.String, @Body body: User): Call diff --git a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt index c8078936eb5..f19c5861dd7 100644 --- a/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +++ b/samples/client/petstore/kotlin-retrofit2/src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt @@ -70,10 +70,10 @@ class ApiClient( baseUrl: String = defaultBasePath, okHttpClientBuilder: OkHttpClient.Builder? = null, serializerBuilder: Moshi.Builder = Serializer.moshiBuilder, - authName: String, - clientId: String, - secret: String, - username: String, + authName: String, + clientId: String, + secret: String, + username: String, password: String ) : this(baseUrl, okHttpClientBuilder, serializerBuilder, arrayOf(authName)) { getTokenEndPoint() @@ -191,7 +191,7 @@ class ApiClient( } } - companion object { + companion object { @JvmStatic val defaultBasePath: String by lazy { System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")