All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openapitools.client.auth.ApiKeyAuth.kt Maven / Gradle / Ivy

Go to download

A demo for deployment to the Central Repository. A kotlin client library for OpenAPI Petstore by org.openapitools

The newest version!
package org.openapitools.client.auth

class ApiKeyAuth(private val location: String, val paramName: String) : Authentication {
    var apiKey: String? = null
    var apiKeyPrefix: String? = null

    override fun apply(query: MutableMap>, headers: MutableMap) {
        val key: String = apiKey ?: return
        val prefix: String? = apiKeyPrefix
        val value: String = if (prefix != null) "$prefix $key" else key
        when (location) {
            "query" -> query[paramName] = listOf(value)
            "header" -> headers[paramName] = value
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy