openapi.templates.kora.kotlinClientRequestMappers.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
/**
* 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 {{package}}
import ru.tinkoff.kora.http.client.common.form.UrlEncodedWriter
import ru.tinkoff.kora.http.client.common.form.MultipartWriter
import ru.tinkoff.kora.http.client.common.request.HttpClientRequestMapper
import ru.tinkoff.kora.http.common.body.HttpBodyOutput;
import ru.tinkoff.kora.common.Context
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client"){{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
interface {{classname}}ClientRequestMappers {
{{#operations}}
{{#operation}}
{{#hasFormParams}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}FormParamRequestMapper{{#vendorExtensions.requiresFormParamMappers}}({{#vendorExtensions.formParamMappers}}
private val {{paramName}}Converter: ru.tinkoff.kora.http.client.common.writer.StringParameterConverter<{{paramType}}>,
{{/vendorExtensions.formParamMappers}} ){{/vendorExtensions.requiresFormParamMappers}}: HttpClientRequestMapper<{{classname}}.{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}FormParam> {
override fun apply(ctx: Context, value: {{classname}}.{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}FormParam): HttpBodyOutput {
{{#vendorExtensions.urlEncodedForm}}
val b = UrlEncodedWriter(){{#formParams}}
value.{{paramName}}?.let { {{#vendorExtensions.requiresMapper}}
b.add("{{baseName}}", {{paramName}}Converter.convert(it))
{{/vendorExtensions.requiresMapper}}{{^vendorExtensions.requiresMapper}}
b.add("{{baseName}}", "${it}")
{{/vendorExtensions.requiresMapper}}
}
{{/formParams}}
return b.write()
{{/vendorExtensions.urlEncodedForm}}{{#vendorExtensions.multipartForm}}
val l = mutableListOf(){{#formParams}}
if (value.{{paramName}} != null) {
{{#isFile}}
val file = value.{{paramName}}
if (file != null) l += file
{{/isFile}}{{^isFile}}
l += ru.tinkoff.kora.http.common.form.FormMultipart.data(
"{{baseName}}",
"${value.{{paramName}}}"
){{/isFile}}
}
{{/formParams}}
return MultipartWriter.write(l)
{{/vendorExtensions.multipartForm}}
}
}
{{/hasFormParams}}
{{/operation}}
{{/operations}}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy