integration/

directory
v1.71.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2026 License: MIT

README

Integration Tests

This directory contains integration tests for oastools. These tests exercise the full pipeline from parsing through generation using declarative YAML scenarios.

Running Tests

# Run all integration tests
make integration-test

# Run what CI runs: the scenarios and the harness tests
make integration-test-scenarios

# Run with verbose output
go test -tags=integration ./integration/... -v -count=1 -timeout=10m

# Run specific scenario category
go test -tags=integration ./integration/... -run="basics/"

# Run single scenario
go test -tags=integration ./integration/... -run="parse-oas30"

# Debug mode (dumps intermediate outputs)
INTEGRATION_DEBUG=1 go test -tags=integration ./integration/... -v

CI runs the scenarios and harness tests on every pull request. The tests under corpus/ run only locally: they skip unless make corpus-download has fetched their specs.

Directory Structure

integration/
├── README.md                 # This file
├── integration_test.go       # Main test entry point
├── harness/                  # Test framework
│   ├── harness.go            # Core types and scenario runner
│   ├── loader.go             # YAML scenario loader
│   ├── pipeline.go           # Pipeline step execution
│   ├── assertions.go         # Result validation helpers
│   ├── problems.go           # Problem injectors for test scenarios
│   └── report.go             # Human-readable output
├── bases/                    # Minimal OAS fixtures
│   ├── petstore-oas2.yaml    # OAS 2.0 baseline
│   ├── petstore-oas30.yaml   # OAS 3.0.3 baseline
│   ├── petstore-oas31.yaml   # OAS 3.1.0 baseline (with webhooks)
│   ├── petstore-oas32.yaml   # OAS 3.2.0 baseline (with QUERY)
│   ├── pointer-oas2.yaml     # OAS 2.0 $refs pointing past a component
│   ├── pointer-oas31.yaml    # OAS 3.1.0 $refs pointing past a component
│   ├── refbody-oas2.yaml     # OAS 2.0 bodies reached by $ref
│   └── refbody-oas30.yaml    # The same API in OAS 3.0
├── scenarios/                # Test scenarios
│   ├── basics/               # Basic parse/validate tests
│   ├── fixer/                # Fixer scenarios (Phase 2)
│   ├── joiner/               # Joiner scenarios (Phase 3)
│   ├── converter/            # Converter scenarios (Phase 4)
│   ├── pipeline/             # Full pipeline scenarios (Phase 5)
│   ├── differ/               # Differ scenarios
│   ├── overlay/              # Overlay scenarios
│   └── edge-cases/           # Edge case scenarios
├── overlays/                 # Overlay documents the scenarios apply
└── corpus/                   # Tests against downloaded real-world specs

Scenario File Format

Scenarios are YAML files that describe a test case:

# Required: Short, descriptive name
name: "Parse OAS 3.0 document"

# Optional: Additional context
description: "Verifies basic OAS 3.0 parsing works"

# Base document from bases/ directory (without .yaml extension)
base: petstore-oas30

# Problems to inject (Phase 2+)
problems:
  missing-path-params:
    - path: "/pets/{petId}/photos/{photoId}"
      method: GET
  generic-schemas:
    - "Response[Pet]"
  duplicate-operationids:
    - id: "getPet"
      count: 3
  csv-enums:
    - schema: "PetStatus"
      values: "available,pending,sold"
  unused-schemas:
    - "OrphanedType"
  empty-paths:
    - "/deprecated/endpoint"

# Pipeline steps to execute (in order)
pipeline:
  - step: parse
  - step: validate
    expect: valid
    assertions:
      - schemas-exist:
          - Pet
          - NewPet

# Optional: Skip this scenario
skip: "Reason for skipping"

# Optional: Mark as known failing
expected-failure: "Known issue #123"

# Optional: Debug settings
debug:
  verbose: true
Pipeline Steps
Step Description Phase
parse Parse the base document 1
parse-all Parse multiple input documents 1
validate Validate the current document 1
validate-all Require every input document to be valid 1
fix Apply fixes to the document 2
fix-all Apply fixes to all documents 2
join Join multiple documents 3
convert Convert between OAS versions 4
convert-all Convert all documents to target version 4
generate Generate client/server code 5
build Compile generated code 5
diff Compare two documents 6
overlay Apply overlay transformations 6

After parse-all of several documents, validate, fix, convert, overlay and generate are refused until a join. The join, validate-all, fix-all and convert-all steps are refused once another step has replaced the documents. Replacing a document drops its validation result and generated code, and a parse or parse-all drops every earlier result. A problem that would inject nothing the fixer or joiner could act on, or replace what the base declares, fails the parse step (the two collision problems replace on purpose).

Expect Values
Value Description
valid Document should be valid (no validation errors)
invalid Document should be invalid (has validation errors)
error Step should fail with an error
success Step should succeed (default)
Assertions

A scenario fails to load if it says something the harness would ignore: an unknown key or fix type, a config value of the wrong type, expect: valid or invalid outside validation, or base, inputs or problems with no step that reads them. expect: error ends the pipeline, needs error-contains and takes no assertions. Each assertion sets exactly one check, and fails if no step produced what it checks.

assertions:
  # Check schema count
  - schema-count: 5

  # Check specific schemas exist
  - schemas-exist:
      - Pet
      - Order

  # Check schemas do NOT exist
  - schemas-not-exist:
      - OrphanedType

  # Check error count
  - error-count: 1

  # Check error message contains substring
  - error-contains: "missing required field"

  # Check fixes applied (Phase 2+)
  - fixes-applied:
      missing-path-params: 2
      generic-schemas: 1

Adding New Scenarios

  1. Create a new YAML file in the appropriate scenarios/ subdirectory
  2. Define the scenario name, base document, and pipeline
  3. Run make integration-test to verify

Example:

name: "My new scenario"
description: "Tests a specific feature"
base: petstore-oas30
pipeline:
  - step: parse
  - step: validate
    expect: valid

Base Fixtures

Base fixtures are minimal but valid OAS documents:

File Version Features
petstore-oas2.yaml 2.0 definitions, body parameters
petstore-oas30.yaml 3.0.3 components, requestBody
petstore-oas31.yaml 3.1.0 webhooks, nullable types
petstore-oas32.yaml 3.2.0 QUERY method
pointer-oas2.yaml 2.0 $refs into a tuple and a response schema
pointer-oas31.yaml 3.1.0 $refs into prefixItems, items and response content
refbody-oas2.yaml 2.0 body and header parameters reached by $ref
refbody-oas30.yaml 3.0.3 the same API, with components.requestBodies

Each petstore base has:

  • 2-3 paths
  • 2-4 schemas
  • Valid structure (passes validation)

Directories

Path Synopsis
Package corpus provides integration tests that exercise cross-package workflows using real-world OpenAPI specifications from the corpus.
Package corpus provides integration tests that exercise cross-package workflows using real-world OpenAPI specifications from the corpus.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL