CommandRoute
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
The action name or sub-resource identifier. Used in URL path generation. Defaults to a dynamic action based on the command class name.
Whether this command route should be active. When false, no endpoint will be generated. Defaults to true.
The HTTP method for the endpoint. Determines the REST operation type.
URL prefix to prepend to the generated path. Useful for API versioning.
Whether to include the aggregate ID in the URL path.
Whether to include the tenant ID in the URL path for multi-tenant scenarios.
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
Controls whether IDs are appended to URL paths.
Marks a command field as a header variable in HTTP requests.
HTTP methods for command routing.
Marks a command field as a path variable in the generated URL.