main.io.github.tabilzad.ktor.output.OpenApiSpec.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktor-docs-plugin Show documentation
Show all versions of ktor-docs-plugin Show documentation
Open API (Swagger) specification Generator for Ktor
package io.github.tabilzad.ktor.output
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import io.github.tabilzad.ktor.ContentType
import io.github.tabilzad.ktor.OpenApiSpecParam
internal typealias ContentSchema = Map
internal typealias BodyContent = Map
data class OpenApiSpec(
val openapi: String = "3.1.0",
val info: Info,
val servers: List? = null,
val paths: Map>,
val components: OpenApiComponents
) {
data class Info(
val title: String,
val description: String,
val version: String
)
data class Server(val url: String)
data class Path(
val summary: String? = null,
val description: String? = null,
val tags: List? = null,
val responses: Map? = null,
val parameters: List? = null,
val requestBody: RequestBody? = null
)
data class RequestBody(
val required: Boolean,
val content: BodyContent
)
interface NamedObject {
var fqName: String?
}
data class ObjectType(
var type: String?,
var properties: MutableMap? = null,
var items: ObjectType? = null,
var enum: List? = null,
@JsonIgnore
override var fqName: String? = null,
var description: String? = null,
@JsonProperty("\$ref")
var ref: String? = null,
@JsonIgnore
var contentBodyRef: String? = null,
var additionalProperties: ObjectType? = null,
var oneOf: List? = null,
var required: MutableList? = null
) : NamedObject
data class PathParam(
override val name: String,
override val `in`: String,
override val required: Boolean = true,
override val description: String? = null,
val schema: SchemaType,
) : OpenApiSpecParam
data class SchemaRef(
val `$ref`: String? = null,
val type: String? = null
)
data class SchemaType(
val type: String? = null,
val items: SchemaRef? = null,
val `$ref`: String? = null,
)
data class ResponseDetails(
val description: String,
val content: BodyContent
)
data class OpenApiComponents(
val schemas: Map
)
}