docs: update docs for 4.0 release (#567)
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
package io.bkbn.kompendium.core
|
||||
|
||||
import io.bkbn.kompendium.core.fixtures.TestHelpers
|
||||
import io.bkbn.kompendium.core.fixtures.TestHelpers.openApiTestAllSerializers
|
||||
import io.bkbn.kompendium.core.util.enrichedComplexGenericType
|
||||
import io.bkbn.kompendium.core.util.enrichedGenericResponse
|
||||
import io.bkbn.kompendium.core.util.enrichedMap
|
||||
import io.bkbn.kompendium.core.util.enrichedNestedCollection
|
||||
import io.bkbn.kompendium.core.util.enrichedSimpleRequest
|
||||
import io.bkbn.kompendium.core.util.enrichedSimpleResponse
|
||||
@ -12,24 +13,27 @@ import io.kotest.core.spec.style.DescribeSpec
|
||||
class KompendiumEnrichmentTest : DescribeSpec({
|
||||
describe("Enrichment") {
|
||||
it("Can enrich a simple request") {
|
||||
TestHelpers.openApiTestAllSerializers("T0055__enriched_simple_request.json") { enrichedSimpleRequest() }
|
||||
openApiTestAllSerializers("T0055__enriched_simple_request.json") { enrichedSimpleRequest() }
|
||||
}
|
||||
it("Can enrich a simple response") {
|
||||
TestHelpers.openApiTestAllSerializers("T0058__enriched_simple_response.json") { enrichedSimpleResponse() }
|
||||
openApiTestAllSerializers("T0058__enriched_simple_response.json") { enrichedSimpleResponse() }
|
||||
}
|
||||
it("Can enrich a nested collection") {
|
||||
TestHelpers.openApiTestAllSerializers("T0056__enriched_nested_collection.json") { enrichedNestedCollection() }
|
||||
openApiTestAllSerializers("T0056__enriched_nested_collection.json") { enrichedNestedCollection() }
|
||||
}
|
||||
it("Can enrich a complex generic type") {
|
||||
TestHelpers.openApiTestAllSerializers(
|
||||
openApiTestAllSerializers(
|
||||
"T0057__enriched_complex_generic_type.json"
|
||||
) { enrichedComplexGenericType() }
|
||||
}
|
||||
it("Can enrich a generic object") {
|
||||
TestHelpers.openApiTestAllSerializers("T0067__enriched_generic_object.json") { enrichedGenericResponse() }
|
||||
openApiTestAllSerializers("T0067__enriched_generic_object.json") { enrichedGenericResponse() }
|
||||
}
|
||||
it("Can enrich a top level list type") {
|
||||
TestHelpers.openApiTestAllSerializers("T0077__enriched_top_level_list.json") { enrichedTopLevelCollection() }
|
||||
openApiTestAllSerializers("T0077__enriched_top_level_list.json") { enrichedTopLevelCollection() }
|
||||
}
|
||||
it("can enrich a map type") {
|
||||
openApiTestAllSerializers("T0078__enriched_top_level_map.json") { enrichedMap() }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -227,3 +227,35 @@ fun Routing.enrichedGenericResponse() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Routing.enrichedMap() {
|
||||
route("/example") {
|
||||
install(NotarizedRoute()) {
|
||||
get = GetInfo.builder {
|
||||
summary(TestModules.defaultPathSummary)
|
||||
description(TestModules.defaultPathDescription)
|
||||
response {
|
||||
responseType<Map<String, TestSimpleRequest>>(
|
||||
enrichment = MapEnrichment("blah") {
|
||||
description = "A nested description"
|
||||
valueEnrichment = ObjectEnrichment("nested") {
|
||||
TestSimpleRequest::a {
|
||||
StringEnrichment("blah-blah-blah") {
|
||||
description = "A simple description"
|
||||
}
|
||||
}
|
||||
TestSimpleRequest::b {
|
||||
NumberEnrichment("blah-blah-blah") {
|
||||
deprecated = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
description("A good response")
|
||||
responseCode(HttpStatusCode.Created)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
103
core/src/test/resources/T0078__enriched_top_level_map.json
Normal file
103
core/src/test/resources/T0078__enriched_top_level_map.json
Normal file
@ -0,0 +1,103 @@
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
|
||||
"info": {
|
||||
"title": "Test API",
|
||||
"version": "1.33.7",
|
||||
"description": "An amazing, fully-ish 😉 generated API spec",
|
||||
"termsOfService": "https://example.com",
|
||||
"contact": {
|
||||
"name": "Homer Simpson",
|
||||
"url": "https://gph.is/1NPUDiM",
|
||||
"email": "chunkylover53@aol.com"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "https://github.com/bkbnio/kompendium/blob/main/LICENSE"
|
||||
}
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
"url": "https://myawesomeapi.com",
|
||||
"description": "Production instance of my API"
|
||||
},
|
||||
{
|
||||
"url": "https://staging.myawesomeapi.com",
|
||||
"description": "Where the fun stuff happens"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"/example": {
|
||||
"get": {
|
||||
"tags": [],
|
||||
"summary": "Great Summary!",
|
||||
"description": "testing more",
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "A good response",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/Map-String-TestSimpleRequest-blah"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"deprecated": false
|
||||
},
|
||||
"parameters": []
|
||||
}
|
||||
},
|
||||
"webhooks": {},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"TestSimpleRequest-nested": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string",
|
||||
"description": "A simple description"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
},
|
||||
"TestSimpleRequest-blah": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"a": {
|
||||
"type": "string",
|
||||
"description": "A simple description"
|
||||
},
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
]
|
||||
},
|
||||
"Map-String-TestSimpleRequest-blah": {
|
||||
"additionalProperties": {
|
||||
"$ref": "#/components/schemas/TestSimpleRequest-blah"
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"securitySchemes": {}
|
||||
},
|
||||
"security": [],
|
||||
"tags": []
|
||||
}
|
Reference in New Issue
Block a user