conformance

package
v1.62.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package conformance reads the OpenAPI Specification conformance suite vendored under testdata/conformance.

The suite is OAI's own, published per version at tests/schema/{pass,fail} on the version branches, plus the six archived 3.0 documents on main. It is vendored at an exact commit rather than fetched, because the schemas version independently of the specification and OAI publishes no endpoint naming the current one. testdata/conformance/sources.txt records what is pinned, along with each version's fixture counts and a digest over their names and contents, and scripts/conformance-vendor.sh is what materializes it.

The digest is what makes the guard exact. 3.2 and 3.3 publish the same 37 pass fixture names and all 37 differ in content, so counts and names alone cannot tell one version's fixtures from the other's.

What the suite is an oracle for matters when reading a result. The fixtures assert validity against the published JSON Schema, not against the prose, and the schema's own README says it covers only the mandatory aspects of the OAS. So the suite is sound in the rejection direction and incomplete in the acceptance one: a fail fixture that oastools accepts is a gap, while a pass fixture that oastools rejects is a triage item that may turn out to be correct. tests/schema/pass/operation-object-example.yaml on 3.2 is the known case, being schema-valid and specification-invalid.

Index

Constants

This section is empty.

Variables

View Source
var Kinds = []Kind{KindPass, KindFail}

Kinds is every kind, for callers walking the whole suite.

Functions

func Dir

func Dir() string

Dir returns the absolute path to the vendored suite, resolved from this file's own location so a caller's working directory does not matter.

It panics rather than returning a path it could not resolve. runtime.Caller does not fail for depth 0 in any ordinary build, and an empty root would be joined away silently, leaving every lookup relative and every version looking like a version that publishes nothing.

Types

type Kind

type Kind string

Kind distinguishes the two halves of the suite. A bare string would sit next to the version at every call site, where the two are indistinguishable to the compiler and a swap reports no fixtures rather than an error.

const (
	// KindPass holds documents the published JSON Schema accepts.
	KindPass Kind = "pass"
	// KindFail holds documents it rejects.
	KindFail Kind = "fail"
)

type Source

type Source struct {
	// Version is the OAS version the fixtures target, as "3.0" or "3.2".
	Version string
	// Ref is the upstream branch the fixtures were taken from. Recorded so a
	// refresh knows what to resolve; the commit is what it actually fetches.
	Ref string
	// Commit is the exact upstream revision vendored, always unabbreviated: an
	// abbreviation can become ambiguous as the upstream repository grows.
	Commit string
	// Subpath is the directory holding pass/ and fail/ upstream. It differs
	// between the version branches and main, which keeps 3.0 under _archive_.
	Subpath string

	// Digest fingerprints every fixture's name and content for this version.
	// Counts alone cannot see a fixture edited in place, nor one version's
	// fixtures vendored into another's directory: 3.2 and 3.3 publish the same
	// 37 pass fixture names and all 37 differ in content.
	Digest string
	// contains filtered or unexported fields
}

Source is one vendored version: where its fixtures came from, how many of each kind sources.txt records, and a digest over their names and contents.

func LoadSources

func LoadSources() ([]Source, error)

LoadSources parses testdata/conformance/sources.txt.

func (Source) ComputeDigest

func (s Source) ComputeDigest() (string, error)

ComputeDigest fingerprints this version's vendored fixtures, by the same construction scripts/conformance-vendor.sh uses: one line per fixture holding its kind, name and content hash, sorted bytewise, hashed.

func (Source) Count

func (s Source) Count(kind Kind) int

Count returns the number of fixtures of one kind that sources.txt records.

func (Source) FixtureDir

func (s Source) FixtureDir(kind Kind) string

FixtureDir returns the directory holding this version's fixtures of one kind.

func (Source) Fixtures

func (s Source) Fixtures(kind Kind) ([]string, error)

Fixtures lists this version's fixture file names of one kind, sorted.

A version that publishes none of a kind has no directory, which yields no names and no error: 3.0 has no fail fixtures. Callers must therefore treat a count of zero as meaningful rather than as an empty success, which is what Count is for.

Jump to

Keyboard shortcuts

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