Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 1.49 KB

File metadata and controls

36 lines (24 loc) · 1.49 KB

OpenApi Validate

GitHub Workflow Status GitHub release (latest SemVer) NuGet Version GitHub

Introduction

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.

Installation

dotnet add package OpenApiValidate

or view on NuGet: https://www.nuget.org/packages/OpenApiValidate

Usage

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