openapi.templates.kora.kotlinClientResponseMappers.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.response.HttpClientResponse
import ru.tinkoff.kora.http.client.common.response.HttpClientResponseMapper
import {{package}}.{{classname}}Responses.*
{{#imports}}import {{import}}
{{/imports}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client"){{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
interface {{classname}}ClientResponseMappers {
{{#operations}}
{{#operation}}
{{#responses}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}{{code}}ApiResponseMapper(
{{#dataType}}
{{#vendorExtensions.hasMapperTag}}@param:{{vendorExtensions.mapperTag}}{{/vendorExtensions.hasMapperTag}}
private val delegate: HttpClientResponseMapper<{{{dataType}}}>
{{/dataType}}
) : HttpClientResponseMapper<{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}ApiResponse> {
override fun apply(response: HttpClientResponse): {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}ApiResponse {
{{#headers}}
val {{#lambda.camelcase}}{{nameInCamelCase}}{{/lambda.camelcase}} = response.headers().getFirst("{{baseName}}"){{#required}} ?: throw NullPointerException("{{baseName}} header is required, but was null"); {{/required}}
{{/headers}}
{{^dataType}}
return {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}ApiResponse{{^vendorExtensions.singleResponse}}.{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}{{#isDefault}}Default{{/isDefault}}{{^isDefault}}{{code}}{{/isDefault}}ApiResponse{{/vendorExtensions.singleResponse}}(
{{#isDefault}}response.code(){{#hasHeaders}}, {{/hasHeaders}}{{/isDefault}}
{{#headers}}{{#lambda.camelcase}}{{nameInCamelCase}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/headers}}
)
{{/dataType}}
{{#dataType}}
return this.delegate.apply(response)
.let { content -> {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}ApiResponse{{^vendorExtensions.singleResponse}}.{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}{{#isDefault}}Default{{/isDefault}}{{^isDefault}}{{code}}{{/isDefault}}ApiResponse{{/vendorExtensions.singleResponse}}(
{{#isDefault}}response.code(), {{/isDefault}}
content{{#hasHeaders}}, {{/hasHeaders}}
{{#headers}}{{#lambda.camelcase}}{{nameInCamelCase}}{{/lambda.camelcase}}{{^-last}}, {{/-last}}{{/headers}}
) }
{{/dataType}}
}
}
{{/responses}}
{{/operation}}
{{/operations}}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy