Generate REST API clients

The DotVVM Command Line tool can also be used to add and update REST API bindings clients.

Even though the DotVVM CLI requires .NET Core, it can be used also for .NET Framework projects with OWIN since it is not a runtime component. It is used only on the developer machines.

Supported commands

Task Syntax Options
Add API Client dotnet dotvvm api create
  • {SwaggerJsonUrl} - URL of the Swagger JSON metadata
  • {Namespace} - namespace in which the API clients will be declared
  • {CSharpClientPath} - relative path to the generate C# client file
  • {TypescriptClientPath} - relative path to the generate TypeScript client file
Update API Client dotnet dotvvm api regen
  • {SwaggerJsonUrl} - (optional) URL of the Swagger JSON metadata; if not specified, all clients will be regenerated

The metadata of REST API Bindings are stored in dotvvm.json file. If any of the parameters needs to be updated, you can change them in this file.

Please note that the API client needs to be registered in DotvvmStartup.cs. See REST API bindings chapter for more details.

Examples

  1. Registering the API client:
dotnet dotvvm api create http://localhost:43852/swagger/v1/swagger.json DotVVM2.Demo.RestApi.Api Api/ApiClient.cs wwwroot/Scripts/ApiClient.ts
  1. Updating the generated clients:
dotnet dotvvm api regen

See also