SchemaTypeHelpers

Utility helpers to work with OpenAPI schema types and $ref dereferencing.

Functions

Link copied to clipboard
fun findSuccessStatusCode(operation: Operation): Int

Finds the first success status code (2xx) from operation responses.

Link copied to clipboard
fun isArray(schema: Schema<*>): Boolean

Determines if the given schema represents an array type.

Link copied to clipboard
fun isBoolean(schema: Schema<*>): Boolean

Determines if the given schema represents a boolean type.

Link copied to clipboard
fun isInteger(schema: Schema<*>): Boolean

Determines if the given schema represents an integer type.

Link copied to clipboard
fun isNumber(schema: Schema<*>): Boolean

Determines if the given schema represents a numeric type (either "integer" or "number").

Link copied to clipboard
fun isObject(schema: Schema<*>): Boolean

Determines if the given schema represents an object type.

Link copied to clipboard
fun isString(schema: Schema<*>): Boolean

Checks if the given schema represents a string type.

Link copied to clipboard
fun resolveExampleRef(example: Example, openAPI: OpenAPI): Example

Resolves an example $ref against OpenAPI components.

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

Resolves a response by status code using OpenAPI matching rules: exact code -> range (e.g. 2XX) -> default.

Link copied to clipboard
fun tryGetParametersFromRef(parameter: Parameter, openAPI: OpenAPI): Parameter

Attempts to dereference a parameter $ref against the OpenAPI components. Returns the dereferenced parameter if found; otherwise returns the original.

Link copied to clipboard
fun tryGetRequestBodyFromRef(requestBody: RequestBody, openAPI: OpenAPI): RequestBody

Attempts to dereference a request body $ref against the OpenAPI components. Returns the dereferenced request body if found; otherwise returns the original.

Link copied to clipboard
fun tryGetSchemaFromRef(schema: Schema<*>, openAPI: OpenAPI): Schema<*>

Attempts to dereference a schema $ref against the OpenAPI components. Returns the dereferenced schema if found; otherwise returns the original schema.