openapi.templates.kora.kotlinClientSecuritySchema.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-generator Show documentation
Show all versions of openapi-generator Show documentation
Kora openapi-generator module
The newest version!
/**
* NOTE: This class is auto generated by Kora OpenAPI Generator (https://openapi-generator.tech) ({{{generatorVersion}}}).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package {{apiPackage}}
import ru.tinkoff.kora.common.Module
import ru.tinkoff.kora.common.Tag
import ru.tinkoff.kora.common.DefaultComponent;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor
import ru.tinkoff.kora.config.common.Config
import ru.tinkoff.kora.http.client.common.interceptor.*
import ru.tinkoff.kora.http.common.auth.*
import ru.tinkoff.kora.http.client.common.auth.*
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
@ru.tinkoff.kora.common.Module
interface ApiSecurity {
{{#authMethods}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
class {{#lambda.classname}}{{name}}{{/lambda.classname}}
{{#isApiKey}}
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class)
fun {{name}}Config(config: Config, extractor: ConfigValueExtractor): String {
val configPath = "{{#hasSecurityConfigPrefix}}{{securityConfigPrefix}}.{{/hasSecurityConfigPrefix}}{{name}}"
val configValue = config.get(configPath)
return extractor.extract(configValue) ?: throw ru.tinkoff.kora.config.common.extractor.ConfigValueExtractionException.missingValueAfterParse(configValue)
}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class)
fun {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class) apiKey: String): ApiKeyHttpClientInterceptor {
val paramLocation = ApiKeyHttpClientInterceptor.ApiKeyLocation.{{#isKeyInQuery}}QUERY{{/isKeyInQuery}}{{#isKeyInHeader}}HEADER{{/isKeyInHeader}}{{#isKeyInCookie}}COOKIE{{/isKeyInCookie}}
return ApiKeyHttpClientInterceptor(paramLocation, "{{keyParamName}}", apiKey)
}
{{/isApiKey}}{{#isBasicBasic}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
data class {{#lambda.classname}}{{name}}{{/lambda.classname}}Config(val username: String, val password: String)
fun {{name}}Config(config: Config, extractor: ConfigValueExtractor<{{#lambda.classname}}{{name}}{{/lambda.classname}}Config>): {{#lambda.classname}}{{name}}{{/lambda.classname}}Config {
val configPath = "{{#hasSecurityConfigPrefix}}{{securityConfigPrefix}}.{{/hasSecurityConfigPrefix}}{{name}}"
val configValue = config.get(configPath)
return extractor.extract(configValue) ?: throw ru.tinkoff.kora.config.common.extractor.ConfigValueExtractionException.missingValueAfterParse(configValue)
}
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class)
fun {{name}}BasicAuthHttpClientTokenProvider(config: {{#lambda.classname}}{{name}}{{/lambda.classname}}Config): BasicAuthHttpClientTokenProvider {
return BasicAuthHttpClientTokenProvider(config.username, config.password)
}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class)
fun {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class) provider: BasicAuthHttpClientTokenProvider): BasicAuthHttpClientInterceptor {
return BasicAuthHttpClientInterceptor(provider)
}
{{/isBasicBasic}}{{#isBasicBearer}}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class)
fun {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class) tokenProvider: HttpClientTokenProvider): BearerAuthHttpClientInterceptor {
return BearerAuthHttpClientInterceptor(tokenProvider)
}
{{/isBasicBearer}}{{#isOAuth}}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class)
fun {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}::class) tokenProvider: HttpClientTokenProvider): BearerAuthHttpClientInterceptor {
return BearerAuthHttpClientInterceptor(tokenProvider)
}
{{/isOAuth}}{{/authMethods}}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy