fix: add missing mapping of BooleanEnrichment to EnrichmentHandler (#655)
This commit is contained in:

committed by
GitHub

parent
4a9165fd3a
commit
636bf65c36
@ -6,6 +6,10 @@
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed missing `BooleanEnrichment` mapping
|
||||
|
||||
### Remove
|
||||
|
||||
---
|
||||
|
@ -10,6 +10,7 @@ import io.bkbn.kompendium.core.fixtures.TestSimpleRequest
|
||||
import io.bkbn.kompendium.core.metadata.GetInfo
|
||||
import io.bkbn.kompendium.core.metadata.PostInfo
|
||||
import io.bkbn.kompendium.core.plugin.NotarizedRoute
|
||||
import io.bkbn.kompendium.enrichment.BooleanEnrichment
|
||||
import io.bkbn.kompendium.enrichment.CollectionEnrichment
|
||||
import io.bkbn.kompendium.enrichment.MapEnrichment
|
||||
import io.bkbn.kompendium.enrichment.NumberEnrichment
|
||||
@ -63,6 +64,9 @@ fun Route.enrichedSimpleRequest() {
|
||||
deprecated = true
|
||||
}
|
||||
}
|
||||
TestSimpleRequest::c {
|
||||
BooleanEnrichment("blah-blah-blah") { }
|
||||
}
|
||||
}
|
||||
)
|
||||
description("A test request")
|
||||
|
@ -109,11 +109,15 @@
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -109,11 +109,15 @@
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -109,11 +109,15 @@
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -144,11 +144,15 @@
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -111,11 +111,15 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -76,11 +76,15 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -111,11 +111,15 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"TestSimpleRequest-blah-blah": {
|
||||
@ -129,11 +133,15 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"List-TestSimpleRequest-blah-blah": {
|
||||
|
@ -64,11 +64,15 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"TestSimpleRequest-blah": {
|
||||
@ -82,11 +86,15 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
},
|
||||
"Map-String-TestSimpleRequest-blah": {
|
||||
|
@ -23,7 +23,8 @@ data class TestRequest(
|
||||
@Serializable
|
||||
data class TestSimpleRequest(
|
||||
val a: String,
|
||||
val b: Int
|
||||
val b: Int,
|
||||
val c: Boolean
|
||||
)
|
||||
|
||||
@Serializable
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.bkbn.kompendium.json.schema.handler
|
||||
|
||||
import io.bkbn.kompendium.enrichment.BooleanEnrichment
|
||||
import io.bkbn.kompendium.enrichment.CollectionEnrichment
|
||||
import io.bkbn.kompendium.enrichment.Enrichment
|
||||
import io.bkbn.kompendium.enrichment.MapEnrichment
|
||||
@ -15,6 +16,7 @@ import io.bkbn.kompendium.json.schema.definition.TypeDefinition
|
||||
object EnrichmentHandler {
|
||||
|
||||
fun Enrichment.applyToSchema(schema: JsonSchema): JsonSchema = when (this) {
|
||||
is BooleanEnrichment -> applyToSchema(schema)
|
||||
is NumberEnrichment -> applyToSchema(schema)
|
||||
is StringEnrichment -> applyToSchema(schema)
|
||||
is CollectionEnrichment<*> -> applyToSchema(schema)
|
||||
@ -39,6 +41,11 @@ object EnrichmentHandler {
|
||||
else -> error("Incorrect enrichment type for enrichment id: ${this.id}")
|
||||
}
|
||||
|
||||
private fun BooleanEnrichment.applyToSchema(schema: JsonSchema): JsonSchema = when (schema) {
|
||||
is TypeDefinition -> schema.copyBooleanEnrichment(this)
|
||||
else -> error("Incorrect enrichment type for enrichment id: ${this.id}")
|
||||
}
|
||||
|
||||
private fun NumberEnrichment.applyToSchema(schema: JsonSchema): JsonSchema = when (schema) {
|
||||
is TypeDefinition -> schema.copyNumberEnrichment(this)
|
||||
else -> error("Incorrect enrichment type for enrichment id: ${this.id}")
|
||||
@ -49,6 +56,13 @@ object EnrichmentHandler {
|
||||
else -> error("Incorrect enrichment type for enrichment id: ${this.id}")
|
||||
}
|
||||
|
||||
private fun TypeDefinition.copyBooleanEnrichment(
|
||||
enrichment: BooleanEnrichment
|
||||
): TypeDefinition = copy(
|
||||
deprecated = enrichment.deprecated,
|
||||
description = enrichment.description,
|
||||
)
|
||||
|
||||
private fun TypeDefinition.copyNumberEnrichment(
|
||||
enrichment: NumberEnrichment
|
||||
): TypeDefinition = copy(
|
||||
|
@ -7,10 +7,14 @@
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
|
@ -7,10 +7,14 @@
|
||||
"b": {
|
||||
"type": "number",
|
||||
"format": "int32"
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
|
@ -9,10 +9,14 @@
|
||||
"type": "number",
|
||||
"format": "int32",
|
||||
"deprecated": true
|
||||
},
|
||||
"c": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"a",
|
||||
"b"
|
||||
"b",
|
||||
"c"
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user