[kotlin][client] add base url key (#10633)

* [kotlin][client] add base url key

* [kotlin][client] update sample projects

* [kotlin][client] add base url key
This commit is contained in:
Bruno Coelho 2021-11-02 15:32:42 +00:00 committed by GitHub
parent df260acc8f
commit 57afa97166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 66 additions and 40 deletions

View File

@ -27,7 +27,7 @@ import {{packageName}}.infrastructure.toMultiValue
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("{{packageName}}.baseUrl", "{{{basePath}}}")
System.getProperties().getProperty(ApiClient.baseUrlKey, "{{{basePath}}}")
}
}

View File

@ -90,6 +90,7 @@ import com.squareup.moshi.adapter
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "{{packageName}}.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -324,9 +324,12 @@ import okhttp3.MediaType.Companion.toMediaType
}
companion object {
@JvmStatic
protected val baseUrlKey = "{{packageName}}.baseUrl"
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("{{packageName}}.baseUrl", "{{{basePath}}}")
System.getProperties().getProperty(baseUrlKey, "{{{basePath}}}")
}
}
}

View File

@ -38,7 +38,7 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://localhost")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://localhost")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -45,6 +45,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -41,7 +41,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -40,7 +40,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -40,7 +40,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -47,6 +47,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ internal class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(bas
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ internal class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(b
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ internal class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(ba
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ internal open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -42,6 +42,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -201,9 +201,12 @@ class ApiClient(
}
companion object {
@JvmStatic
protected val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(baseUrlKey, "http://petstore.swagger.io/v2")
}
}
}

View File

@ -204,9 +204,12 @@ class ApiClient(
}
companion object {
@JvmStatic
protected val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(baseUrlKey, "http://petstore.swagger.io/v2")
}
}
}

View File

@ -201,9 +201,12 @@ class ApiClient(
}
companion object {
@JvmStatic
protected val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(baseUrlKey, "http://petstore.swagger.io/v2")
}
}
}

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -38,7 +38,7 @@ class EnumApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {

View File

@ -39,7 +39,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath)
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -38,7 +38,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
companion object {
@JvmStatic
val defaultBasePath: String by lazy {
System.getProperties().getProperty("org.openapitools.client.baseUrl", "http://petstore.swagger.io/v2")
System.getProperties().getProperty(ApiClient.baseUrlKey, "http://petstore.swagger.io/v2")
}
}

View File

@ -44,6 +44,7 @@ open class ApiClient(val baseUrl: String) {
var username: String? = null
var password: String? = null
var accessToken: String? = null
const val baseUrlKey = "org.openapitools.client.baseUrl"
@JvmStatic
val client: OkHttpClient by lazy {