openapi.templates.kora.javaClientSecuritySchema.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.Config;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor;
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
public interface ApiSecurity {
{{#authMethods}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
static final class {{#lambda.classname}}{{name}}{{/lambda.classname}} {}
{{#isApiKey}}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class)
default String {{name}}Config(Config config, ConfigValueExtractor extractor) {
var configPath = "{{#hasSecurityConfigPrefix}}{{securityConfigPrefix}}.{{/hasSecurityConfigPrefix}}{{name}}";
var configValue = config.get(configPath);
var parsed = extractor.extract(configValue);
if (parsed == null) {
throw ru.tinkoff.kora.config.common.extractor.ConfigValueExtractionException.missingValueAfterParse(configValue);
}
return parsed;
}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class)
default ApiKeyHttpClientInterceptor {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class) String apiKey) {
var paramLocation = ApiKeyHttpClientInterceptor.ApiKeyLocation.{{#isKeyInQuery}}QUERY{{/isKeyInQuery}}{{#isKeyInHeader}}HEADER{{/isKeyInHeader}}{{#isKeyInCookie}}COOKIE{{/isKeyInCookie}};
return new ApiKeyHttpClientInterceptor(paramLocation, "{{keyParamName}}", apiKey);
}
{{/isApiKey}}{{#isBasicBasic}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
static record {{#lambda.classname}}{{name}}{{/lambda.classname}}Config(String username, String password){}
default {{#lambda.classname}}{{name}}{{/lambda.classname}}Config {{name}}Config(Config config, ConfigValueExtractor<{{#lambda.classname}}{{name}}{{/lambda.classname}}Config> extractor) {
var configPath = "{{#hasSecurityConfigPrefix}}{{securityConfigPrefix}}.{{/hasSecurityConfigPrefix}}{{name}}";
var configValue = config.get(configPath);
var parsed = extractor.extract(configValue);
if (parsed == null) {
throw ru.tinkoff.kora.config.common.extractor.ConfigValueExtractionException.missingValueAfterParse(configValue);
}
return parsed;
}
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class)
default BasicAuthHttpClientTokenProvider {{name}}BasicAuthHttpClientTokenProvider({{#lambda.classname}}{{name}}{{/lambda.classname}}Config config) {
return new BasicAuthHttpClientTokenProvider(config.username(), config.password());
}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class)
default BasicAuthHttpClientInterceptor {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class) HttpClientTokenProvider tokenProvider) {
return new BasicAuthHttpClientInterceptor(tokenProvider);
}
{{/isBasicBasic}}{{#isBasicBearer}}
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class)
default BearerAuthHttpClientInterceptor {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class) HttpClientTokenProvider tokenProvider) {
return new BearerAuthHttpClientInterceptor(tokenProvider);
}
{{/isBasicBearer}}{{#isOAuth}}
@DefaultComponent
@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class)
default BearerAuthHttpClientInterceptor {{name}}HttpClientAuthInterceptor(@Tag(ApiSecurity.{{#lambda.classname}}{{name}}{{/lambda.classname}}.class) HttpClientTokenProvider tokenProvider) {
return new BearerAuthHttpClientInterceptor(tokenProvider);
}
{{/isOAuth}}{{/authMethods}}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy