spectest

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package spectest provides an end-to-end test harness for the OpenAPI generator. It runs the real pipeline — analyzer.AnalyzeProject -> generator.Generate — over fixture projects under testdata/ and validates the emitted document against the OpenAPI 3.0 specification in-process.

It exists because the per-package unit suites build models.Project by hand, so they never exercise the analyze->generate path that the binary actually runs (which is precisely why functionally-broken specs ship while every unit test stays green). This harness closes that blind spot with two checks per fixture: structural validation via kin-openapi (the primary, deterministic, network-free gate) and a golden-file comparison of the exact emitted YAML.

The exported helpers (Generate, Validate) are reusable by later generator work so every fidelity change can assert real wire output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(ctx context.Context, dir string) (string, error)

Generate runs the analyzer and generator over the project rooted at dir and returns the emitted OpenAPI document as a string. ctx is the first parameter per the repo's context-first convention; it is honoured for early cancellation and will thread into the analyzer/generator once those become context-aware.

func Validate

func Validate(ctx context.Context, data []byte) error

Validate parses spec data (YAML or JSON) and validates it against OpenAPI 3.0 in-process, honouring ctx for cancellation. This is the primary structural gate: it is deterministic and needs no network or external toolchain, unlike the redocly step run in CI.

It delegates to specvalidate.Validate, the reusable validator that also backs the `validate` subcommand and the generator's `--validate` flag.

Types

This section is empty.

Jump to

Keyboard shortcuts

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