Routing
The proxy generator builds API route strings for commands and queries from the C# namespace hierarchy. These options let you adjust the resulting routes.
API Prefix
Section titled “API Prefix”<PropertyGroup> <CratisProxiesApiPrefix>api</CratisProxiesApiPrefix></PropertyGroup>The CratisProxiesApiPrefix value is prepended to every generated route. Default is api.
Example: Namespace MyApp.Orders.Registration with prefix api → /api/orders/registration.
Excluding Type Names from Routes
Section titled “Excluding Type Names from Routes”By default, the command or query type name is appended to the route:
- Command
RegisterAuthor→/api/authors/registration/register-author - Query
GetActiveAuthors→/api/authors/listing/get-active-authors
Setting either flag to true removes the type name from the route:
<PropertyGroup> <CratisProxiesSkipCommandNameInRoute>true</CratisProxiesSkipCommandNameInRoute> <CratisProxiesSkipQueryNameInRoute>true</CratisProxiesSkipQueryNameInRoute></PropertyGroup>Automatic Conflict Detection
Section titled “Automatic Conflict Detection”When the type name is skipped, the generator detects route conflicts automatically. If multiple commands or queries share the same namespace, their type names are re-added to prevent collisions. This matches the runtime endpoint mapping behavior exactly.
Example with a single command in MyApp.Orders.Commands:
CreateOrderCommand → /api/orders/commandsExample with multiple commands in MyApp.Orders.Commands:
CreateOrderCommand → /api/orders/commands/create-order-commandUpdateOrderCommand → /api/orders/commands/update-order-commandDeleteOrderCommand → /api/orders/commands/delete-order-commandproxygenerator assembly.dll output-path \ --api-prefix=v1 \ --skip-command-name-in-route \ --skip-query-name-in-route