All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.io.github.tabilzad.ktor.DataBag.kt Maven / Gradle / Ivy

package io.github.tabilzad.ktor

import com.fasterxml.jackson.annotation.JsonProperty
import io.github.tabilzad.ktor.output.OpenApiSpec

interface OpenApiSpecParam {
    val name: String
    val `in`: String
    val required: Boolean
    val description: String?
}

internal interface ParamSpec {
    val name: String
    val description: String?
}

internal data class PathParamSpec(
    override val name: String,
    override val description: String? = null,
) : ParamSpec

internal data class QueryParamSpec(
    override val name: String,
    override val description: String? = null,
    val isRequired: Boolean = false
) : ParamSpec

internal data class KtorRouteSpec(
    val path: String,
    val parameters: List?,
    val method: String,
    val body: OpenApiSpec.ObjectType,
    val summary: String?,
    val description: String?,
    val tags: Set?,
    val responses: Map?
)

sealed class KtorElement {
    abstract var path: String?
    abstract var tags: Set?

    abstract fun newInstance(tags: Set?): KtorElement
}

enum class ExpType(val labels: List) {
    ROUTE(listOf("route")),
    METHOD(listOf("get", "post", "put", "patch", "delete")),
    RECEIVE(listOf("receive"))
}

internal data class EndPoint(
    override var path: String?,
    val method: String = "",
    var body: OpenApiSpec.ObjectType? = OpenApiSpec.ObjectType(type = "object"),
    var parameters: Set? = null,
    var description: String? = null,
    var summary: String? = null,
    override var tags: Set? = null,
    var responses: Map? = null
) : KtorElement() {
    override fun newInstance(tags: Set?): EndPoint {
        return copy(tags = tags)
    }
}

data class DocRoute(
    override var path: String? = "/",
    val children: MutableList = mutableListOf(),
    override var tags: Set? = null
) : KtorElement() {
    override fun newInstance(tags: Set?): DocRoute {
        return copy(tags = tags)
    }
}

enum class ContentType {
    @JsonProperty("application/json")
    APPLICATION_JSON,

    @JsonProperty("text/plain")
    TEXT_PLAIN;
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy