Skip to content

b1sted/SwaggerTester

Repository files navigation

SwaggerTester

Automated API Contract Testing tool. Parses OpenAPI specs and validates backend responses on the fly.

Java 21 Release Version License CLI Tool

FeaturesLimitationsBuild and RunLicense


SwaggerTester is a lightweight CLI utility for automated API contract testing. It parses OpenAPI 3.x specifications from a remote URL, extracts all endpoints, generates realistic fake payloads based on field names and schema types, and fires actual HTTP requests against a target server — validating that responses match the declared contract.

Note

At its current stage, the tool is tailored for the CorporateDirectory API. The target URL and some behaviors are hardcoded to match that project (see Limitations below).


Console Demo


Features

  • Dynamic Parsing: Parses OpenAPI 3.x specs from a remote URL using swagger-parser, resolving $ref links across components.
  • Zero Configuration Tests: No manual test cases needed. Builds EndpointTask instances automatically from all declared paths and operations.
  • Smart Payload Generation: Generates realistic fake data using datafaker, with field-name-aware heuristics (email, username, password, etc.) and type-based fallbacks.
  • CRUD-Ordered Execution: Sorts endpoints by resource and method priority (POST → GET → PATCH → PUT → DELETE) to ensure create-before-read ordering.
  • Auth Header Injection: Automatically injects Authorization: Basic <token> from .env, and omits it for expected 404 scenarios.
  • Colored Console Output: Prints [PASS] / [FAIL] tags with ANSI colors and a grand total summary at the end.

Limitations

  1. Target URL: the OpenAPI spec and HTTP requests are sent to a hardcoded http://localhost:8080.
  2. Negative testing: due to the Spring Security configuration of the target API, the auth token is intentionally omitted, and the expected status is 404 Not Found instead of the standard 401 Unauthorized.

Build and Run

Prerequisites

  • JDK 21+
  • Maven

Setup

Clone the repository and configure credentials:

git clone https://github.com/b1sted/SwaggerTester.git
cd SwaggerTester
cp .env.example .env
# Fill in BASIC_AUTHENTICATION in .env with your Base64-encoded "user:password"

Run

./mvnw clean package
java -jar target/swagger-tester.jar

Make sure your target API is running at http://localhost:8080 before starting.

License

Distributed under the GNU GPL v3.0.

You are free to use, modify, distribute, and sell this software. However, any derivative works or modifications must be distributed under the same license, the source code must be made openly available, and you must preserve the copyright notice and license file.

Full text of the license: LICENSE.

About

Automated API Contract Testing tool. Parses OpenAPI specs and validates backend responses on the fly.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages