ResponseBodyGenerator

fun interface ResponseBodyGenerator

Strategy for deriving a fallback response body from a schema.

ResponseExampleExtractor invokes this generator only when the specification declares no usable explicit example for the negotiated media type, so explicit-example precedence stays in one place while the generated-body slot remains pluggable.

This is a fun interface, so Kotlin callers can pass a lambda and Java callers can pass a lambda via SAM conversion:

new ResponseExampleExtractor((schema, api) -> myGenerator.generate(schema, api));

Functions

Link copied to clipboard
abstract fun generate(schema: Schema<*>, openAPI: OpenAPI): Any?

Generates a response body example for the given schema.