com.ancientlightstudios.example.features.server.NullableValueContext.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-kotlin-openapi-test Show documentation
Show all versions of quarkus-kotlin-openapi-test Show documentation
An example application using the Kotlin OpenAPI generator.
// THIS IS A GENERATED FILE. DO NOT EDIT!
package com.ancientlightstudios.example.features.server
import com.ancientlightstudios.example.custom.*
import com.ancientlightstudios.example.features.server.model.OperationError
import com.ancientlightstudios.quarkus.kotlin.openapi.*
import com.ancientlightstudios.quarkus.kotlin.openapi.extension.*
import com.fasterxml.jackson.databind.ObjectMapper
import jakarta.ws.rs.core.HttpHeaders
import org.jboss.resteasy.reactive.RestResponse
class NullableValueContext(
val request: Maybe,
private val objectMapper: ObjectMapper,
private val headers: HttpHeaders
) : RequestContext, ResponseWithGenericStatus {
override fun status(
status: Int,
mediaType: String?,
body: Any?,
vararg headers: Pair
): Nothing = throw RequestHandledSignal(RestResponse.ResponseBuilder.create(status).entity(body)
.type(mediaType).apply {
headers.forEach {
headers(it.first, it.second)
}
}.build())
fun noContent(): Nothing = status(204, null, null)
fun badRequest(body: OperationError): Nothing = status(400, "application/json", body.asJson().asString(objectMapper))
override fun rawHeaderValue(name: String) = headers.getRequestHeader(name)?.firstOrNull()
override fun rawHeaderValues(name: String) = (headers.getRequestHeader(name) ?: listOf())
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy