CommandRoute

annotation class CommandRoute(val action: String = DEFAULT_COMMAND_ACTION, val enabled: Boolean = true, val method: CommandRoute.Method = Method.DEFAULT, val prefix: String = "", val appendIdPath: CommandRoute.AppendPath = AppendPath.DEFAULT, val appendTenantPath: CommandRoute.AppendPath = AppendPath.DEFAULT, val appendOwnerPath: CommandRoute.AppendPath = AppendPath.DEFAULT)

Configures routing and HTTP endpoint generation for command classes.

This annotation defines how commands are exposed as REST API endpoints, including the HTTP method, URL structure, and path parameters. It's essential for generating OpenAPI documentation and enabling HTTP-based command dispatching.

Example usage:

@CommandRoute(
action = "create",
method = CommandRoute.Method.POST,
appendIdPath = CommandRoute.AppendPath.NEVER, // No ID in path for creation
appendTenantPath = CommandRoute.AppendPath.ALWAYS
)
data class CreateOrderCommand(
@TenantId
val tenantId: String,
val items: List<OrderItem>
)

// Generates: POST /orders/tenant/{tenantId}/create

Parameters

action

The action name or sub-resource identifier. Used in URL path generation. Defaults to a dynamic action based on the command class name.

enabled

Whether this command route should be active. When false, no endpoint will be generated. Defaults to true.

method

The HTTP method for the endpoint. Determines the REST operation type.

prefix

URL prefix to prepend to the generated path. Useful for API versioning.

appendIdPath

Whether to include the aggregate ID in the URL path.

appendTenantPath

Whether to include the tenant ID in the URL path for multi-tenant scenarios.

appendOwnerPath

Whether to include the owner ID in the URL path for ownership-based routing.

See also

for available HTTP methods

for path appending options

for current API documentation approach

Types

Link copied to clipboard

Controls whether IDs are appended to URL paths.

Link copied to clipboard
annotation class HeaderVariable(val name: String = "", val nestedPath: Array<String> = [], val required: Boolean = true)

Marks a command field as a header variable in HTTP requests.

Link copied to clipboard

HTTP methods for command routing.

Link copied to clipboard
annotation class PathVariable(val name: String = "", val nestedPath: Array<String> = [], val required: Boolean = true)

Marks a command field as a path variable in the generated URL.

Properties

Link copied to clipboard

action name or sub resource name

Link copied to clipboard
Link copied to clipboard
val enabled: Boolean = true
Link copied to clipboard
Link copied to clipboard