Skip to content

alvaroacev/oas-api-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

OAS API Validator

This project is meant to validate JSON requests and responses against a known Open API Specification (OAS) API contract. The logic is based on Atlasian Swagger Request Validator framework

Requests and responses validations implemented are bassed on com.atlassian.oai.validator.OpenApiInteractionValidator which is instantiated with a local OAS file. The validator returns a com.atlassian.oai.validator.report.ValidationReport which is inspected to determine success or failure.

Features

  • The project exposes two different sets of unit tests: ** one designed to be independent of any HTTP library and validate the API responses stored as file resources ** the other based on spring-web org.springframework.web.client.RestTemplate which calls a remote service provider and validate the response against a OAS 3.0 API contract
  • The project also implements a main method to run the validator standalone, see usage for more details

Usage

See unit test for how the main method is used. The main expects following arguments:

usage: Open API validator
 -apiPath <apiPath>         HTTP method (e.g. /payments/{id}/transactions).
 -httpMethod <httpMethod>   HTTP method (e.g. GET, PUT, POST, DELETE.
 -oas <oas>                 Open API Specification URI in YAML format.
 -request <request>         HTTP request URI in JSON formart.
 -response <response>       HTTP response URI in JSON formart.

From the command line you can run the project by using following command:

java -cp open-api-validator.jar oas.api.validator.OpenAPIValidator -oas ./api-contract.yaml -response ./response.json -apiPath /user/status -httpMethod GET

About

Swagger and Open API Specification OAS validator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages