ResponseExampleExtractor

class ResponseExampleExtractor(schemaExampleValueGenerator: SchemaExampleValueGenerator)

Extracts expected response examples from OpenAPI operations.

This class handles the extraction of response examples from OpenAPI specifications, using a defined selection order:

  • Response: exact status -> range (e.g. 2XX) -> default

  • Media types: JSON-like -> XML -> other (alphabetical)

  • Example selection: explicit examples are chosen by media type priority; schema-derived fallback is JSON-like only

Constructors

Link copied to clipboard
constructor(schemaExampleValueGenerator: SchemaExampleValueGenerator)

Functions

Link copied to clipboard
fun extractExpectedResponseExample(operation: Operation, openAPI: OpenAPI, statusCode: Int): Any?

Extracts expected response example from an operation for the given status code.

fun extractExpectedResponseExample(operation: Operation, openAPI: OpenAPI, statusCode: Int, exampleName: String?): Any?

Extracts expected response example from an operation for the given status code and example name.