This package is used to validate a HTTP request/response against an OpenAPI specification.
This can be integrated in to a test suite to ensure the responses returned by your API conform to the OpenAPI specification.
dotnet add package OpenApiValidateor view on NuGet: https://www.nuget.org/packages/OpenApiValidate
See more detailed documentation for setup of the validator.
// Load the OpenApiDocument
var documentLoadResult = await OpenApiDocument.LoadAsync("https://petstore.swagger.io/v2/swagger.json");
// Create the OpenApiValidator
var validator = new OpenApiValidator(documentLoadResult.Document);
// Validate the request and response
var response = await httpClient.GetAsync("https://petstore.swagger.io/v2/store/inventory");
await openApiValidator.Validate(response); // will throw an exception if fails validation