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