Example Encoding
Example objects are automatically serialized (as json) and added to the OpenAPI specification. The encoding of example values can be customized in the plugin configuration. If no encoder is specified, the example value will be encoded by swagger.
Pre-Defined Example Encoders
Explicitly use the internal swagger example encoder.
install(OpenApi) {
examples {
encoder = ExampleEncoder.internal()
}
}
More Information
Use kotlinx.serialization to encode example values.
install(OpenApi) {
examples {
encoder = ExampleEncoder.kotlinx()
}
}
More Information
Custom Example Encoder
The example encoder can be completely replaced by an own implementation.
install(OpenApi) {
examples {
encoder { type, example ->
TOOD()
}
}
}
Custom "toString()" Example Encoder
install(OpenApi) {
examples {
encoder { type, example ->
example.toString()
}
}
}