Skip to content

atlassian/openapi-request-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,012 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenAPI Request Validator

(Formerly "Swagger Request Validator")

maven-central

A Java library for validating HTTP request/responses against an OpenAPI / Swagger specification.

Designed to be used independently of any HTTP library or framework, the library can be used to validate request/responses from almost any source (e.g. in a REST client, in unit tests that use mocked responses, in Pact tests etc.)

Key features

  • Standalone - no dependencies on HTTP libraries or frameworks
  • Adapters for commonly used HTTP libraries and testing frameworks
  • JSON Schema validation support - including schema references
  • Fine-grained control over which validations are applied
  • Support for Swagger v2 and OpenAPI v3 specifications

See Features for more details.

IMPORTANT

Prior to v3.0.0 this project was known as swagger-request-validator and used maven artifact IDs of the form swagger-request-validator-*. This was changed in the v3.0.0 release to better align with the underlying OpenAPI/Swagger terminology.

Usage

See the examples module for examples on how the library is used.

Usage details for specific modules can be found in the READMEs for those modules.

<dependency>
    <groupId>com.atlassian.oai</groupId>
    <artifactId>openapi-request-validator-core</artifactId>
    <version>${openapi-request-validator.version}</version>
</dependency>

Project structure

See individual module READMEs for more information, including how to use each module.

openapi-request-validator-core

maven-central

The core validator logic.

Provides a standalone validator and uses an implementation-agnostic abstraction of HTTP request/responses that can be adapted to any 3rd party implementation.

openapi-request-validator-pact

maven-central

Adapters for validating Pact request/response expectations with the OpenAPI / Swagger validator, shortening the feedback loop when writing Consumer tests.

Includes a JUnit rule that adds OpenAPI / Swagger validation to the Pact-JVM consumer test execution.

openapi-request-validator-wiremock-junit5

maven-central

Adapters for validating WireMock HTTP mocks against an OpenAPI / Swagger specification.

Includes a drop-in replacement for the WireMockRule that adds validation to mocked interactions, giving you confidence that your mocks reflect reality.

openapi-request-validator-restassured

maven-central

Adapters for validating given-when-then interactions from the REST Assured testing library against an OpenAPI / Swagger specification.

Useful for e.g. ensuring your service implementation matches its API specification.

openapi-request-validator-mockmvc

maven-central

Adapters for validating interactions using the Spring 7+ MVC Test Framework against an OpenAPI / Swagger specification.

Includes a ResultMatcher that allows you to assert your service implementation matches its API specification.

Compatible with Spring 7+.

openapi-request-validator-spring-webmvc

maven-central

Adapter for validating interactions using the Spring 7+ Web MVC framework against an OpenAPI / Swagger specification during runtime in a production environment.

Useful for ensuring that the incoming requests match your service's API specification.

Compatible with Spring 7+, Spring Boot 4+ and the Jakarta namespace. Requires JDK17+.

openapi-request-validator-spring-web-client

maven-central

Adapter for adding OpenAPI / Swagger validation to the Spring Web HTTP client.

Useful for ensuring that a service implementation matches its API specification.

openapi-request-validator-examples

maven-central

Working code samples that demonstrate the features of the openapi-request-validator and its various adapters.

Building and testing

The project uses Maven 3.9+. We recommend using mvnvm or similar.

The project requires JDK21+ to build. We recommend using sdkman or similar to manage JDK versions.

To build the project:

>> mvn clean install

To run the project tests:

>> mvn test

To do a full build:

>> mvn clean verify javadoc:jar

License

Copyright (c) 2016 Atlassian and others. Apache 2.0 licensed, see LICENSE.txt file.

About

A Java library for validating request/responses against a OpenAPI / Swagger specification

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors