dev.crashteam.openapi.keanalytics.api.ApiUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openapi-ke-analytics Show documentation
Show all versions of openapi-ke-analytics Show documentation
Generates jar artifact containing compiled openapi classes based on generated openapi yaml files
The newest version!
package dev.crashteam.openapi.keanalytics.api;
import java.nio.charset.StandardCharsets;
import org.springframework.core.io.buffer.DefaultDataBuffer;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
public class ApiUtil {
public static Mono getExampleResponse(ServerWebExchange exchange, MediaType mediaType, String example) {
ServerHttpResponse response = exchange.getResponse();
response.getHeaders().setContentType(mediaType);
byte[] exampleBytes = example.getBytes(StandardCharsets.UTF_8);
DefaultDataBuffer data = new DefaultDataBufferFactory().wrap(exampleBytes);
return response.writeWith(Mono.just(data));
}
}