1. Atlassian
  2. Tooling and Automation
  3. swagger-request-validator

Overview

HTTPS SSH

Swagger Request Validator

build-status maven-central

A Java library for validating HTTP request/responses against a Swagger/OpenAPI 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

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>swagger-request-validator-core</artifactId>
    <version>${swagger-request-validator.version}</version>
</dependency>

Project structure

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

swagger-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.

swagger-request-validator-pact

maven-central

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

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

swagger-request-validator-wiremock

maven-central

Adapters for validating WireMock HTTP mocks against a Swagger/OAI specification.

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

swagger-request-validator-restassured

maven-central

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

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

swagger-request-validator-mockmvc

maven-central

Adapters for validating interactions using the Spring MVC Test Framework against a Swagger/OAI specification.

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

swagger-request-validator-examples

maven-central

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

Building and testing

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

To build the project:

>> mvn clean install

To run the project tests:

>> mvn test

Contributors

Pull requests, issues and comments welcome. For pull requests:

  • Add tests for new features and bug fixes
  • Follow the existing style (checkstyle checking is enabled by default in builds)
  • Separate unrelated changes into multiple pull requests

Please ensure that your branch builds successfully before you open your PR. The Pipelines build won't run by default on a remote branch, so either enable Pipelines for your fork or run the build locally:

mvn clean verify javadoc:javadoc

See the existing issues for things to start contributing. If you want to start working on an issue, please assign the ticket to yourself and mark it as open so others know it is in progress.

For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.

Atlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).

Prior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.

License

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