get

fun <P : Any> get(name: String? = null, requestType: KClass<P>, block: RequestSpecificationBuilder<P>.() -> Unit): BuildingStep<P>(source)

Defines a GET stub that matches a typed request body of type P.

Example:

mokksy.get(name = "fetch-item", requestType = MyRequest::class) {
path("/items/1")
} respondsWith {
body = """{"id":1}"""
}

Return

A BuildingStep for response configuration and stub registration.

Parameters

name

Optional identifier for this stub.

requestType

The KClass of the expected request body.

block

Lambda to configure the RequestSpecificationBuilder.

Type Parameters

P

The expected type of the request body.


fun <P : Any> get(configuration: StubConfiguration, requestType: KClass<P>, block: RequestSpecificationBuilder<P>.() -> Unit): BuildingStep<P>(source)

Defines a GET stub that matches a typed request body of type P using a full StubConfiguration.

Return

A BuildingStep for response configuration and stub registration.

Parameters

configuration

The StubConfiguration controlling stub behaviour (name, priority, etc.).

requestType

The KClass of the expected request body.

block

Lambda to configure the RequestSpecificationBuilder.

Type Parameters

P

The expected type of the request body.


Defines a GET stub with a String request body.

Return

A BuildingStep for response configuration and stub registration.

Parameters

block

Lambda to configure the RequestSpecificationBuilder.


Defines a GET stub with a String request body and a full StubConfiguration.

Return

A BuildingStep for response configuration and stub registration.

Parameters

configuration

The StubConfiguration controlling stub behaviour (name, priority, etc.).

block

Lambda to configure the RequestSpecificationBuilder.