Skip to content

AButler/openapi-validate

Repository files navigation

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

About

NuGet package for validating requests and responses against OpenApi specifications

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •