respondsWith

infix fun <T : Any> respondsWith(block: suspend ResponseDefinitionBuilder<P, T>.() -> Unit)(source)

Associates the current RequestSpecification with a response definition. This method is part of a fluent API for defining mappings between requests and responses.

The block lambda is a suspend function, so it may call suspend APIs such as dev.mokksy.mokksy.request.CapturedRequest.body without blocking.

Parameters

P

The type of the request payload.

T

The type of the response body.

block

A suspend lambda applied to a ResponseDefinitionBuilder, used to configure the response definition.


fun <T : Any> respondsWith(responseType: KClass<T>, block: suspend ResponseDefinitionBuilder<P, T>.() -> Unit)(source)

Associates the current RequestSpecification with a response definition.

This overload accepts an explicit responseType class token to help the compiler infer the type parameter T when it cannot be determined from the block alone (type-witness pattern). The responseType value itself is not used at runtime.

Parameters

T

The type of the response body.

responseType

A KClass token for T, used only for type inference at the call site.

block

A suspend lambda applied to a ResponseDefinitionBuilder, used to configure the response definition.