response for status
This commit is contained in:
@ -2,7 +2,7 @@ package org.leafygreens.kompendium.models
|
||||
|
||||
// TODO Oof -> https://swagger.io/specification/#media-type-object
|
||||
data class OpenApiSpecMediaType(
|
||||
val schema: OpenApiSpecReferencable, // TODO sheesh -> https://swagger.io/specification/#schema-object needs to be referencable
|
||||
val schema: OpenApiSpecSchema, // TODO sheesh -> https://swagger.io/specification/#schema-object
|
||||
val example: String? = null, // TODO Enforce type? then serialize?
|
||||
val examples: Map<String, String>? = null, // needs to be mutually exclusive with example
|
||||
val encoding: Map<String, String>? = null // todo encoding object -> https://swagger.io/specification/#encoding-object
|
||||
|
@ -1,14 +0,0 @@
|
||||
package org.leafygreens.kompendium.models
|
||||
|
||||
sealed class OpenApiSpecParameterSchema(
|
||||
val type: String,
|
||||
)
|
||||
|
||||
data class OpenApiSpecParameterSchemaArray<T: OpenApiSpecParameterSchema >(
|
||||
val items: T
|
||||
) : OpenApiSpecParameterSchema("array")
|
||||
|
||||
data class OpenApiSpecParameterSchemaString(
|
||||
val default: String,
|
||||
val `enum`: Set<String>? = null
|
||||
) : OpenApiSpecParameterSchema("string")
|
@ -30,7 +30,7 @@ data class OpenApiSpecParameter(
|
||||
val allowEmptyValue: Boolean = false,
|
||||
val style: String? = null,
|
||||
val explode: Boolean? = false,
|
||||
val schema: OpenApiSpecParameterSchema? = null
|
||||
val schema: OpenApiSpecSchema? = null
|
||||
) : OpenApiSpecReferencable()
|
||||
|
||||
data class OpenApiSpecRequest(
|
||||
|
@ -0,0 +1,21 @@
|
||||
package org.leafygreens.kompendium.models
|
||||
|
||||
sealed class OpenApiSpecSchema
|
||||
|
||||
sealed class OpenApiSpecSchemaTyped(
|
||||
val type: String,
|
||||
) : OpenApiSpecSchema()
|
||||
|
||||
data class OpenApiSpecSchemaArray<T: OpenApiSpecSchema >(
|
||||
val items: T
|
||||
) : OpenApiSpecSchemaTyped("array")
|
||||
|
||||
data class OpenApiSpecSchemaString(
|
||||
val default: String,
|
||||
val `enum`: Set<String>? = null
|
||||
) : OpenApiSpecSchemaTyped("string")
|
||||
|
||||
// TODO In Kt 1.5 Should be able to reference external sealed classes
|
||||
data class OpenApiSpecSchemaRef(
|
||||
val `$ref`: String
|
||||
) : OpenApiSpecSchema()
|
@ -9,13 +9,14 @@ import org.leafygreens.kompendium.models.OpenApiSpecInfoContact
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecInfoLicense
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecMediaType
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecParameter
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecParameterSchemaArray
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecParameterSchemaString
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaArray
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaString
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecPathItem
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecPathItemOperation
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecReferenceObject
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecRequest
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecResponse
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecSchemaRef
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecServer
|
||||
import org.leafygreens.kompendium.models.OpenApiSpecTag
|
||||
|
||||
@ -85,10 +86,10 @@ object TestData {
|
||||
description = "Pet object that needs to be added to the store",
|
||||
content = mapOf(
|
||||
"application/json" to OpenApiSpecMediaType(
|
||||
schema = OpenApiSpecReferenceObject(`$ref` = "#/components/schemas/Pet")
|
||||
schema = OpenApiSpecSchemaRef(`$ref` = "#/components/schemas/Pet")
|
||||
),
|
||||
"application/xml" to OpenApiSpecMediaType(
|
||||
schema = OpenApiSpecReferenceObject(`$ref` = "#/components/schemas/Pet")
|
||||
schema = OpenApiSpecSchemaRef(`$ref` = "#/components/schemas/Pet")
|
||||
)
|
||||
),
|
||||
required = true
|
||||
@ -122,10 +123,10 @@ object TestData {
|
||||
description = "Pet object that needs to be added to the store",
|
||||
content = mapOf(
|
||||
"application/json" to OpenApiSpecMediaType(
|
||||
schema = OpenApiSpecReferenceObject(`$ref` = "#/components/schemas/Pet")
|
||||
schema = OpenApiSpecSchemaRef(`$ref` = "#/components/schemas/Pet")
|
||||
),
|
||||
"application/xml" to OpenApiSpecMediaType(
|
||||
schema = OpenApiSpecReferenceObject(`$ref` = "#/components/schemas/Pet")
|
||||
schema = OpenApiSpecSchemaRef(`$ref` = "#/components/schemas/Pet")
|
||||
)
|
||||
)
|
||||
),
|
||||
@ -157,14 +158,38 @@ object TestData {
|
||||
required = true,
|
||||
style = "form",
|
||||
explode = true,
|
||||
schema = OpenApiSpecParameterSchemaArray(
|
||||
items = OpenApiSpecParameterSchemaString(
|
||||
schema = OpenApiSpecSchemaArray(
|
||||
items = OpenApiSpecSchemaString(
|
||||
default = "available",
|
||||
`enum` = setOf("available", "pending", "sold")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
responses = mapOf(
|
||||
"200" to OpenApiSpecResponse(
|
||||
description = "successful operation",
|
||||
content = mapOf(
|
||||
"application/xml" to OpenApiSpecMediaType(
|
||||
schema = OpenApiSpecSchemaArray(
|
||||
items = OpenApiSpecSchemaRef("#/components/schemas/Pet")
|
||||
)
|
||||
),
|
||||
"application/json" to OpenApiSpecMediaType(
|
||||
schema = OpenApiSpecSchemaArray(
|
||||
items = OpenApiSpecSchemaRef("#/components/schemas/Pet")
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
"400" to OpenApiSpecResponse(
|
||||
description = "Invalid status value",
|
||||
content = mapOf()
|
||||
)
|
||||
),
|
||||
security = listOf(mapOf(
|
||||
"petstore_auth" to listOf("write:pets", "read:pets")
|
||||
))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -118,7 +118,37 @@
|
||||
"type" : "array"
|
||||
}
|
||||
} ],
|
||||
"deprecated" : false
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"content" : {
|
||||
"application/xml" : {
|
||||
"schema" : {
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/Pet"
|
||||
},
|
||||
"type" : "array"
|
||||
}
|
||||
},
|
||||
"application/json" : {
|
||||
"schema" : {
|
||||
"items" : {
|
||||
"$ref" : "#/components/schemas/Pet"
|
||||
},
|
||||
"type" : "array"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid status value",
|
||||
"content" : { }
|
||||
}
|
||||
},
|
||||
"deprecated" : false,
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write:pets", "read:pets" ]
|
||||
} ]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user