RequestSpecification

open class RequestSpecification<P : Any>(val method: <Error class: unknown class><<Error class: unknown class>>? = null, val path: <Error class: unknown class><String>? = null, val headers: List<<Error class: unknown class><<Error class: unknown class>>> = listOf(), val body: List<<Error class: unknown class><P?>> = listOf(), val bodyString: List<<Error class: unknown class><String?>> = listOf(), val priority: Int? = DEFAULT_STUB_PRIORITY, requestType: KClass<P>)

Represents a specification for matching incoming HTTP requests based on defined criteria, such as HTTP method, request path, and request body.

This class is used to define the criteria against which incoming requests are tested. It provides functionality for checking whether a given request satisfies the specified conditions and supports prioritization for defining matching order.

Parameters

P

type of the request payload

Constructors

Link copied to clipboard
constructor(method: <Error class: unknown class><<Error class: unknown class>>? = null, path: <Error class: unknown class><String>? = null, headers: List<<Error class: unknown class><<Error class: unknown class>>> = listOf(), body: List<<Error class: unknown class><P?>> = listOf(), bodyString: List<<Error class: unknown class><String?>> = listOf(), priority: Int? = DEFAULT_STUB_PRIORITY, requestType: KClass<P>)

Properties

Link copied to clipboard
val body: List<<Error class: unknown class><P?>>

List of matchers for the request body as a P. All matchers must pass for a match to succeed.

Link copied to clipboard
val bodyString: List<<Error class: unknown class><String?>>

List of matchers for the request body as a String. All matchers must pass for a match to succeed.

Link copied to clipboard
val headers: List<<Error class: unknown class><<Error class: unknown class>>>

List of matchers for Ktor Headers object. All matchers must pass for a match to succeed.

Link copied to clipboard
val method: <Error class: unknown class><<Error class: unknown class>>? = null

Matcher for the HTTP method of the request. If null, the method is not validated.

Link copied to clipboard
val path: <Error class: unknown class><String>? = null

Matcher for the request path. If null, the path is not validated.

Link copied to clipboard

The priority value used for comparing different specifications. Lower values indicate higher priority. Default value is DEFAULT_STUB_PRIORITY

Functions

Link copied to clipboard
suspend fun matches(request: <Error class: unknown class>): <Error class: unknown class><Boolean>