SchemaExampleValueGenerator

class SchemaExampleValueGenerator(valueProviders: List<SchemaValueProvider>, schemaMerger: SchemaMerger = SchemaMerger(), options: SchemaExampleValueGeneratorOptions = SchemaExampleValueGeneratorOptions())

Generates synthetic example values from OpenAPI schemas for use in tests.

Provider order matters: the first provider that returns a non-null value wins.

Constructors

Link copied to clipboard
constructor(valueProviders: List<SchemaValueProvider>, schemaMerger: SchemaMerger = SchemaMerger(), options: SchemaExampleValueGeneratorOptions = SchemaExampleValueGeneratorOptions())

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.

Link copied to clipboard
fun getExampleArrayValues(name: String, schema: Schema<*>, openAPI: OpenAPI): List<Any>

Produces an example array value that satisfies array constraints.

Link copied to clipboard
fun getExampleArrayValuesByItem(name: String, arraySchema: Schema<*>, itemSchema: Schema<*>, openAPI: OpenAPI, depth: Int = 0, visitedRefs: MutableSet<String> = mutableSetOf()): List<Any>
Link copied to clipboard
fun getExampleObject(name: String, schema: Schema<*>, openAPI: OpenAPI): Map<String, Any>

Generates a valid object based on the provided schema.

Link copied to clipboard
fun getExampleValue(name: String, schema: Schema<*>, openAPI: OpenAPI, variationIndex: Int = 0): Any

Retrieves the example value for a given parameter based on its schema.