Enrichment
Kompendium allows users to enrich their data types with additional information. This can be done by defining a TypeEnrichment
object and passing it to the enrichment
parameter of the relevant requestType
or responseType
.
An enrichment must provide an id
field that is unique to the data class that is being enriched. This is because under the hood, Kompendium appends this id to the data class identifier in order to support multiple different enrichments on the same data class.
If you provide duplicate ids, all but the first enrichment will be ignored, as Kompendium will view that as a cache hit, and skip analyzing the new enrichment.
Nested Enrichments
Enrichments are portable and composable, meaning that we can take an enrichment for a child data class and apply it inside a parent data class using the typeEnrichment
property.
Available Enrichments
All enrichments support the following properties:
description -> Provides a reader friendly description of the field in the object
deprecated -> Indicates that the field is deprecated and should not be used
String
minLength -> The minimum length of the string
maxLength -> The maximum length of the string
pattern -> A regex pattern that the string must match
contentEncoding -> The encoding of the string
contentMediaType -> The media type of the string
Numbers
minimum -> The minimum value of the number
maximum -> The maximum value of the number
exclusiveMinimum -> Indicates that the minimum value is exclusive
exclusiveMaximum -> Indicates that the maximum value is exclusive
multipleOf -> Indicates that the number must be a multiple of the provided value
Arrays
minItems -> The minimum number of items in the array
maxItems -> The maximum number of items in the array
uniqueItems -> Indicates that the array must contain unique items
Last updated