forked from loafle/openapi-generator-original
[kotlin][jvm-retrofit2] Update templates (#7592)
* Fix indent of return tag * Trim trailing whitespace * Update samples Co-authored-by: Jim Schubert <james.schubert@gmail.com>
This commit is contained in:
parent
1dec9ebfb8
commit
5bac98cd99
@ -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")
|
||||
|
@ -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<Interceptor, OAuth> {
|
||||
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}}}")
|
||||
|
@ -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<Pet>]>
|
||||
* @return [Call]<[kotlin.collections.List<Pet>]>
|
||||
*/
|
||||
@GET("pet/findByStatus")
|
||||
fun findPetsByStatus(@Query("status") status: CSVParams): Single<kotlin.collections.List<Pet>>
|
||||
@ -58,7 +58,7 @@ interface PetApi {
|
||||
* - 400: Invalid tag value
|
||||
*
|
||||
* @param tags Tags to filter by
|
||||
* @return [Call]<[kotlin.collections.List<Pet>]>
|
||||
* @return [Call]<[kotlin.collections.List<Pet>]>
|
||||
*/
|
||||
@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<Pet>
|
||||
@ -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")
|
||||
|
@ -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<kotlin.String, kotlin.Int>]>
|
||||
* @return [Call]<[kotlin.collections.Map<kotlin.String, kotlin.Int>]>
|
||||
*/
|
||||
@GET("store/inventory")
|
||||
fun getInventory(): Single<kotlin.collections.Map<kotlin.String, kotlin.Int>>
|
||||
@ -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<Order>
|
||||
@ -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<Order>
|
||||
|
@ -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<User>): 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<User>): 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<User>
|
||||
@ -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<kotlin.String>
|
||||
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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<Unit>
|
||||
@ -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<Unit>
|
||||
@ -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<Pet>]>
|
||||
* @return [Call]<[kotlin.collections.List<Pet>]>
|
||||
*/
|
||||
@GET("pet/findByStatus")
|
||||
fun findPetsByStatus(@Query("status") status: CSVParams): Call<kotlin.collections.List<Pet>>
|
||||
@ -57,7 +57,7 @@ interface PetApi {
|
||||
* - 400: Invalid tag value
|
||||
*
|
||||
* @param tags Tags to filter by
|
||||
* @return [Call]<[kotlin.collections.List<Pet>]>
|
||||
* @return [Call]<[kotlin.collections.List<Pet>]>
|
||||
*/
|
||||
@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<Pet>
|
||||
@ -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<Unit>
|
||||
@ -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")
|
||||
|
@ -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<Unit>
|
||||
@ -27,7 +27,7 @@ interface StoreApi {
|
||||
* Responses:
|
||||
* - 200: successful operation
|
||||
*
|
||||
* @return [Call]<[kotlin.collections.Map<kotlin.String, kotlin.Int>]>
|
||||
* @return [Call]<[kotlin.collections.Map<kotlin.String, kotlin.Int>]>
|
||||
*/
|
||||
@GET("store/inventory")
|
||||
fun getInventory(): Call<kotlin.collections.Map<kotlin.String, kotlin.Int>>
|
||||
@ -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<Order>
|
||||
@ -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<Order>
|
||||
|
@ -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<Unit>
|
||||
@ -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<User>): Call<Unit>
|
||||
@ -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<User>): Call<Unit>
|
||||
@ -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<Unit>
|
||||
@ -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<User>
|
||||
@ -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<kotlin.String>
|
||||
@ -91,7 +91,7 @@ interface UserApi {
|
||||
* Responses:
|
||||
* - 0: successful operation
|
||||
*
|
||||
* @return [Call]<[Unit]>
|
||||
* @return [Call]<[Unit]>
|
||||
*/
|
||||
@GET("user/logout")
|
||||
fun logoutUser(): Call<Unit>
|
||||
@ -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<Unit>
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user