MockConfiguration

@Serializable
data class MockConfiguration(val apiGroups: List<ApiGroupConfig>)

Root configuration for network mocking, loaded from mocks.json.

This data class represents the complete mock configuration that integrators define in their composeResources/files/networkmocks/mocks.json file. It contains all API group configurations, each of which defines a set of shared endpoints and the environments (deployment stages) in which those endpoints are reachable.

File Location

The configuration file should be placed at:

composeResources/files/networkmocks/mocks.json

JSON Structure

{
"apiGroups": [
{
"id": "my-backend",
"name": "My Backend",
"endpoints": [
{
"id": "getUser",
"name": "Get User",
"path": "/v1/users/{userId}",
"method": "GET"
}
],
"environments": [
{
"id": "staging",
"name": "Staging",
"url": "https://staging.api.example.com"
},
{
"id": "production",
"name": "Production",
"url": "https://api.example.com"
}
]
}
]
}

Usage Example

val repository = MockConfigRepository("files/networkmocks/mocks.json")
val config = repository.loadConfiguration().getOrNull()

config?.apiGroups?.forEach { group ->
println("Group: ${group.id}")
group.environments.forEach { env ->
println(" Environment: ${env.id} - ${env.url}")
}
group.endpoints.forEach { endpoint ->
println(" Endpoint: ${endpoint.method} ${endpoint.path}")
}
}

See also

Constructors

Link copied to clipboard
constructor(apiGroups: List<ApiGroupConfig>)

Properties

Link copied to clipboard

List of API group configurations, each representing a named logical backend with its shared endpoints and environment-specific base URLs