Validates at build time that the OpenAPI specification files extracted from the ASP.NET Core Web API being built conform to Workleap API guidelines.
Depending if the user chose the ValidateContract or GenerateContract development mode this MSBuild task will:
- Install tools: OasDiff, Spectral, SwashbuckleCLI
- Generate the OpenAPI specification file from the associated Web API
- Validate OpenAPI spec with Workleap Spectral rules
- Compare the given OpenAPI specification file with the generated one
For the TLDR version:
- The entry point is
ValidateOpenApiTask.ExecuteAsync()
and will be executed after the referencing project is built. This is defined in./src/Workleap.OpenApi.MSBuild/msbuild/tools/Workleap.OpenApi.MSBuild.targets
as aUsingTask.TaskName
- The default value are defined in the property group on the target
ValidateOpenApi
in this file./src/Workleap.OpenApi.MSBuild/msbuild/tools/Workleap.OpenApi.MSBuild.targets
- Users can select whether to validate the API with frontend or backend ruleset depending on how they configure the
OpenApiServiceProfile
MSBuild property (backend
(default) orfrontend
).
Since it's a MSBuild task named ValidateOpenApi
you can run it this command: msbuild /t:ValidateOpenApi
. ./src/WebApiDebugger
already have some preconfigured in launchSettings.json
that you can run in debug.
Note: Before executing this task it will build the project.
Warming: validate your IDE is in Configuration:Debug otherwise the execution will not be done on the most recent code.