Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kotlin] Add OkHttpClient.Builder to ApiClient. #7907

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ open class ApiClient(val baseUrl: String) {
protected val XmlMediaType = "application/xml"

@JvmStatic
val client : OkHttpClient = OkHttpClient()
val client by lazy {
builder.build()
}

@JvmStatic
val builder: OkHttpClient.Builder = OkHttpClient.Builder()

@JvmStatic
var defaultHeaders: Map<String, String> by ApplicationDelegates.setOnce(mapOf(ContentType to JsonMediaType, Accept to JsonMediaType))
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-string/docs/UserApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Get user by user name
//import io.swagger.client.models.*

val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
try {
val result : User = apiInstance.getUserByName(username)
println(result)
Expand All @@ -230,7 +230,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ open class ApiClient(val baseUrl: String) {
protected val XmlMediaType = "application/xml"

@JvmStatic
val client : OkHttpClient = OkHttpClient()
val client by lazy {
builder.build()
}

@JvmStatic
val builder: OkHttpClient.Builder = OkHttpClient.Builder()

@JvmStatic
var defaultHeaders: Map<String, String> by ApplicationDelegates.setOnce(mapOf(ContentType to JsonMediaType, Accept to JsonMediaType))
Expand Down Expand Up @@ -85,9 +90,9 @@ open class ApiClient(val baseUrl: String) {
RequestMethod.DELETE -> Request.Builder().url(url).delete()
RequestMethod.GET -> Request.Builder().url(url)
RequestMethod.HEAD -> Request.Builder().url(url).head()
RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(body!!, contentType))
RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body!!, contentType))
RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body!!, contentType))
RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(body, contentType))
RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body, contentType))
RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body, contentType))
RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class Order (
* Order Status
* Values: placed,approved,delivered
*/
enum class Status(val value: kotlin.Any){
enum class Status(val value: kotlin.String){

placed("placed"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class Pet (
* pet status in the store
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.Any){
enum class Status(val value: kotlin.String){

available("available"),

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin-threetenbp/docs/UserApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Get user by user name
//import io.swagger.client.models.*

val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
try {
val result : User = apiInstance.getUserByName(username)
println(result)
Expand All @@ -230,7 +230,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ open class ApiClient(val baseUrl: String) {
protected val XmlMediaType = "application/xml"

@JvmStatic
val client : OkHttpClient = OkHttpClient()
val client by lazy {
builder.build()
}

@JvmStatic
val builder: OkHttpClient.Builder = OkHttpClient.Builder()

@JvmStatic
var defaultHeaders: Map<String, String> by ApplicationDelegates.setOnce(mapOf(ContentType to JsonMediaType, Accept to JsonMediaType))
Expand Down Expand Up @@ -85,9 +90,9 @@ open class ApiClient(val baseUrl: String) {
RequestMethod.DELETE -> Request.Builder().url(url).delete()
RequestMethod.GET -> Request.Builder().url(url)
RequestMethod.HEAD -> Request.Builder().url(url).head()
RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(body!!, contentType))
RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body!!, contentType))
RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body!!, contentType))
RequestMethod.PATCH -> Request.Builder().url(url).patch(requestBody(body, contentType))
RequestMethod.PUT -> Request.Builder().url(url).put(requestBody(body, contentType))
RequestMethod.POST -> Request.Builder().url(url).post(requestBody(body, contentType))
RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ data class Order (
* Order Status
* Values: placed,approved,delivered
*/
enum class Status(val value: kotlin.Any){
enum class Status(val value: kotlin.String){

placed("placed"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ data class Pet (
* pet status in the store
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.Any){
enum class Status(val value: kotlin.String){

available("available"),

Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/kotlin/docs/UserApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Get user by user name
//import io.swagger.client.models.*

val apiInstance = UserApi()
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.
try {
val result : User = apiInstance.getUserByName(username)
println(result)
Expand All @@ -230,7 +230,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **kotlin.String**| The name that needs to be fetched. Use user1 for testing. |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class UserApi(basePath: kotlin.String = "http://petstore.swagger.io/v2") : ApiCl
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ open class ApiClient(val baseUrl: String) {
protected val XmlMediaType = "application/xml"

@JvmStatic
val client : OkHttpClient = OkHttpClient()
val client by lazy {
builder.build()
}

@JvmStatic
val builder: OkHttpClient.Builder = OkHttpClient.Builder()

@JvmStatic
var defaultHeaders: Map<String, String> by ApplicationDelegates.setOnce(mapOf(ContentType to JsonMediaType, Accept to JsonMediaType))
Expand Down