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

committed by
GitHub

parent
4a9165fd3a
commit
636bf65c36
@ -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