openapi.templates.kora.javaClientResponseMappers.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 java.util.concurrent.CompletionStage;
import java.util.concurrent.CompletableFuture;
import {{package}}.{{classname}}Responses.*;
{{#imports}}import {{import}};
{{/imports}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client"){{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}
public interface {{classname}}ClientResponseMappers {
{{#operations}}
{{#operation}}
{{#responses}}
@ru.tinkoff.kora.common.annotation.Generated("openapi generator kora client")
final class {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}{{code}}ApiResponseMapper implements HttpClientResponseMapper<{{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}ApiResponse> {
{{#dataType}}
private final HttpClientResponseMapper<{{{dataType}}}> delegate;
public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}{{code}}ApiResponseMapper({{#vendorExtensions.hasMapperTag}}@{{vendorExtensions.mapperTag}}{{/vendorExtensions.hasMapperTag}} HttpClientResponseMapper<{{{dataType}}}> delegate) {
this.delegate = delegate;
}
{{/dataType}}
@Override
public {{#lambda.titlecase}}{{operationId}}{{/lambda.titlecase}}ApiResponse apply(HttpClientResponse response) throws java.io.IOException {
{{#headers}}
var {{#lambda.camelcase}}{{nameInCamelCase}}{{/lambda.camelcase}} = response.headers().getFirst("{{baseName}}");
{{#required}}
if ({{#lambda.camelcase}}{{nameInCamelCase}}{{/lambda.camelcase}} == null) {
throw new NullPointerException("{{baseName}} header is required, but was null");
}
{{/required}}
{{/headers}}
{{^dataType}}
return new {{#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}}
var content = this.delegate.apply(response);
return new {{#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