mirror of
https://github.com/bronson-g/kompendium.git
synced 2025-12-23 22:18:33 -05:00
use oas Header class instead of ResponseHeader class
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package io.bkbn.kompendium.core.metadata
|
||||
|
||||
import io.bkbn.kompendium.enrichment.TypeEnrichment
|
||||
import io.bkbn.kompendium.oas.payload.Header
|
||||
import io.bkbn.kompendium.oas.payload.MediaType
|
||||
import io.bkbn.kompendium.oas.payload.ResponseHeader
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import kotlin.reflect.KType
|
||||
import kotlin.reflect.typeOf
|
||||
@@ -14,7 +14,7 @@ class ResponseInfo private constructor(
|
||||
val description: String,
|
||||
val examples: Map<String, MediaType.Example>?,
|
||||
val mediaTypes: Set<String>,
|
||||
val responseHeaders: Map<String, ResponseHeader>?
|
||||
val responseHeaders: Map<String, Header>?
|
||||
) {
|
||||
|
||||
companion object {
|
||||
@@ -32,9 +32,9 @@ class ResponseInfo private constructor(
|
||||
private var description: String? = null
|
||||
private var examples: Map<String, MediaType.Example>? = null
|
||||
private var mediaTypes: Set<String>? = null
|
||||
private var responseHeaders: Map<String, ResponseHeader>? = null
|
||||
private var responseHeaders: Map<String, Header>? = null
|
||||
|
||||
fun responseHeaders(headers: Map<String, ResponseHeader>) = apply {
|
||||
fun responseHeaders(headers: Map<String, Header>) = apply {
|
||||
this.responseHeaders = headers
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import io.bkbn.kompendium.core.util.TestModules.defaultPathSummary
|
||||
import io.bkbn.kompendium.core.util.TestModules.defaultResponseDescription
|
||||
import io.bkbn.kompendium.core.util.TestModules.rootPath
|
||||
import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
import io.bkbn.kompendium.oas.payload.Header
|
||||
import io.bkbn.kompendium.oas.payload.Parameter
|
||||
import io.bkbn.kompendium.oas.payload.ResponseHeader
|
||||
import io.ktor.http.HttpHeaders
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.call
|
||||
@@ -69,11 +69,11 @@ fun Routing.responseHeaders() {
|
||||
description(defaultResponseDescription)
|
||||
responseHeaders(
|
||||
mapOf(
|
||||
HttpHeaders.ETag to ResponseHeader(
|
||||
HttpHeaders.ETag to Header(
|
||||
TypeDefinition.STRING,
|
||||
"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag"
|
||||
),
|
||||
HttpHeaders.LastModified to ResponseHeader(
|
||||
HttpHeaders.LastModified to Header(
|
||||
TypeDefinition.STRING,
|
||||
"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified"
|
||||
),
|
||||
|
||||
@@ -41,13 +41,17 @@
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag"
|
||||
"description": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag",
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
},
|
||||
"Last-Modified": {
|
||||
"schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified"
|
||||
"description": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Last-Modified",
|
||||
"required": true,
|
||||
"deprecated": false
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
|
||||
@@ -16,7 +16,7 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
data class Response(
|
||||
val description: String,
|
||||
val headers: Map<String, ResponseHeader>? = null,
|
||||
val headers: Map<String, Header>? = null,
|
||||
val content: Map<String, MediaType>? = null,
|
||||
val links: Map<String, Link>? = null
|
||||
)
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
package io.bkbn.kompendium.oas.payload
|
||||
|
||||
import io.bkbn.kompendium.json.schema.definition.JsonSchema
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Describes a header object
|
||||
* https://spec.openapis.org/oas/v3.1.0#header-object
|
||||
*
|
||||
* @param description A brief description of the parameter.
|
||||
* This is valid only for query parameters and allows sending a parameter with an empty value.
|
||||
*/
|
||||
@Serializable
|
||||
data class ResponseHeader(
|
||||
val schema: JsonSchema,
|
||||
val description: String? = null
|
||||
// todo support styling https://spec.openapis.org/oas/v3.1.0#style-values
|
||||
)
|
||||
Reference in New Issue
Block a user