go-openapi conformance suites

Conformance test suites for JSON and YAML parsers.

This library generates test suites.

Each document is generated, and its verdict comes from the grammar published by its specification.

Status

Fork me

Early days: the API is still in flux. Documentation and code are still being honed…

Getting started

Each suite is published as a gzipped JSON Lines file.

You can read it from any language with a JSON reader and a base64 decoder.

You don’t need Go or this library to work with the suite. See Read a corpus.

Go

To use the oracles, the generators, or the embedded corpus from Go:

go get github.com/go-openapi/conformance-suites

Then see Score a parser.

Licensing

SPDX-FileCopyrightText: Copyright 2025-2026 go-swagger maintainers

This library ships under the Apache-2.0 license. The vendored YAML Test Suite and JSONTestSuite fixtures ship under the MIT License.

Contributing

Issues and pull requests welcome.

See the shared go-openapi contributing guidelines and the per-repo notes in project/.


  • Two routes into a corpus: read the file from any language, or use the Go API.
  • How a corpus is built and labelled: the oracle, tags and stances, coverage, meanings.
  • One suite per grammar: JSON today, YAML next.
  • The corpus file format and the tag vocabulary, field by field.
  • Repo-level information for github.com/go-openapi/conformance-suites.

    Contributing guidelines and maintainer documentation are shared across the go-openapi organization.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Subsections of go-openapi conformance suites

Getting started

A conformance suite is a corpus of test cases, published as a single file. You can read it with any JSON reader and a base64 decoder, and score your parser, written in any language.

Go users can also import this module, to run the oracles or the generators, or to load the small corpus embedded in the module without downloading anything.

  • Read a corpus file from any language: the header, the cases, and what to check before scoring.
  • Score a Go parser against the embedded JSON corpus with suite, stance and jsoncorpus.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Subsections of Getting started

Read a corpus

A corpus is one file. This page reads it with jq and with Python, and turns a case into an expected outcome without the Go packages. File format lists every field.

Get a corpus file

Each release tag holds the compact corpus of each suite, at a fixed path in the repository:

suitefile
JSONjson/testdata/json-compact.jsonl.gz
YAMLyaml/corpus/testdata/yaml-compact.jsonl.gz

Download a file at a release tag, so your tests read the same cases until you choose to move:

tag=v0.0.4
base=https://raw.githubusercontent.com/go-openapi/conformance-suites/${tag}

curl -sSLO "${base}/json/testdata/json-compact.jsonl.gz"
curl -sSLO "${base}/yaml/corpus/testdata/yaml-compact.jsonl.gz"

The releases page lists the tags. The header records what built the file: gunzip -c yaml-compact.jsonl.gz | head -1 | jq '{tier, cases, generator, digest}'.

Note

Releases do not attach corpus files yet. The plan is for each release to attach the compact and extended corpora of both suites, with a checksum list. Until then, the tag is the way to pin a corpus.

To get the full JSON corpus, build it with Go:

f, err := os.Create("json-full.jsonl.gz")
if err != nil {
	return err
}
defer f.Close()

return jsoncorpus.Full().Write(f)

Choose a tier

tierJSON casesYAML casesuse it towhere to get it
compact392128279run on every change: it keeps up to 16 cases per coverage signaturethe repository, at a release tag
extended11982112578run before you release: five times the documents, with the same quotaplanned as a release asset
full144396built on demandrun on a schedule: it keeps every generated documentbuild it with Go, as above

The header’s tier field says which one a file holds. Coverage explains what the compact tier leaves out.

The layout

  • The file is gzip-compressed JSON Lines.
  • Line 1 is the header.
  • Every following line is one case.
  • A case’s src holds the test document in base64, because many documents are not valid UTF-8.

Read it with jq

The header:

gunzip -c json-compact.jsonl.gz | head -1 | jq .

Every tag the corpus uses, with its stage and whether the specification settles it:

gunzip -c json-compact.jsonl.gz | head -1 | jq -r '.vocabulary[] | "\(.tag) \(.stage) \(.settled // "open")"'

How many cases carry each tag:

gunzip -c json-compact.jsonl.gz | tail -n +2 | jq -r '.tags[]?' | sort | uniq -c

The documents carrying one tag, decoded:

gunzip -c json-compact.jsonl.gz | tail -n +2 \
  | jq -r 'select(.tags | index("string/lone-surrogate")) | .src | @base64d'

@base64d writes text, so use it only on documents that are valid UTF-8. For the bytes of any case, pipe .src to base64 -d.

Read it in another language

Any language with gzip, JSON and base64 can read a corpus. In Python:

import base64
import gzip
import json

with gzip.open("json-compact.jsonl.gz", "rt", encoding="utf-8") as f:
    header = json.loads(f.readline())
    if header["format"] != 4:
        raise SystemExit(f"unsupported format {header['format']}")

    cases = [json.loads(line) for line in f]

if len(cases) != header["cases"]:
    raise SystemExit(f"truncated: {len(cases)} of {header['cases']} cases")

for case in cases:
    src = base64.b64decode(case["src"])
    tags = case.get("tags", [])
    # score src here

The example checks the format first and the length last, as File format asks.

Check the vocabulary

Before you score anything, read header.vocabulary and decide your parser’s position on every tag in it that is not settled. A tag you have no position on leaves every case carrying it unscored. A newer corpus can add a tag, so run this check on every new file.

Turn a case into an expected outcome

You need three things about your parser:

  • Its stage: how far it takes a document. parse for a parser that only checks syntax, compose for one that builds a tree and resolves aliases, construct for one that builds native values.
  • Its stand on each open tag: it accepts such documents, refuses them on purpose, or does not guarantee either answer.
  • Which settled rules it declines. A parser that never resolves aliases cannot check a rule about them, and declines it.

Then work through these steps in order. The first step that gives an answer decides.

  1. Leave out the tags past your stage. A tag whose stage in the header comes later than your parser’s stage asks nothing of it.
  2. Settled tags. Go through the case’s tags in the order it lists them. For a tag whose spec has settled:
    • if you decline its rule, the case is not scored;
    • if settled is reject, expect a rejection;
    • if settled is accept, the construct is legal and the grammar still decides, so go on.
  3. Open tags. Go through the remaining tags in order:
    • you refuse it: expect a rejection;
    • you have no position, or you do not guarantee either answer: the case is not scored;
    • you accept it, and the case is opaque: the case is not scored, because nothing can say what the bytes denote without the decoder your parser uses;
    • you accept it: go on.
  4. The grammar refuses it. If wellFormed is false, expect a rejection. A document that does not parse does not compose or construct either.
  5. The verdict’s reach. verdictAt is the last stage at which the grammar’s acceptance is evidence. If it is earlier than your parser’s stage, the case is not scored. An absent verdictAt means parse.
  6. Otherwise, expect acceptance.

A case that is not scored tells nothing about your parser. Skip it, and do not count it as a pass. The Go package stance runs the same steps in Table.Expect; see Score a parser in Go.

Info

The YAML Test Suite view, a jq filter that writes in.yaml, in.json and error for each case, comes with the YAML pages.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Score a parser in Go

This page scores the standard library’s json.Valid against the JSON compact corpus embedded in the module. Replace json.Valid with a call to your own parser.

Install

go get github.com/go-openapi/conformance-suites

The module requires go1.26 or newer.

Load a corpus

jsoncorpus.CompactSuite returns the header and the cases of the compact corpus embedded in the module:

header, cases, err := jsoncorpus.CompactSuite()

To use a corpus file you downloaded or built, open it and call suite.ReadAll:

f, err := os.Open("json-full.jsonl.gz")
if err != nil {
	return err
}
defer f.Close()

header, cases, err := suite.ReadAll(f)

You can build the full JSON corpus with jsoncorpus.Full().Write(w).

Declare your parser’s positions

The JSON grammar does not settle everything: a parser may refuse a byte order mark, or accept an unpaired surrogate escape, and still conform to RFC 8259. Each such property has a tag. A stance.Table records your parser’s position on every tag:

var stdlib = stance.Table{
	Name:    "encoding/json Valid",
	Because: "checks syntax only, and requires UTF-8 with no byte order mark",
	At:      stance.Parse,
	Speaks:  jsoncorpus.Vocabulary(),
	Stands: map[stance.Tag]stance.Stand{
		stance.TagBOM:               stance.Refuses,
		stance.TagNotUTF8:           stance.Accepts,
		stance.TagUTF16:             stance.Refuses,
		stance.TagUTF32:             stance.Refuses,
		jsoncorpus.TagLoneSurrogate: stance.Accepts,
		jsoncorpus.TagDeepNesting:   stance.Refuses,
	},
}
  • Name and Because appear in the reasons that Table.Expect returns.
  • At is the last stage your parser reaches. json.Valid only checks syntax, so it stops at stance.Parse, and the corpus does not ask it about number/out-of-range, which arises at stance.Construct.
  • Speaks gives the stage of each tag. Use the vocabulary of the grammar under test.
  • Stands gives your position on each tag:
    standmeaningeffect on a case carrying the tag
    stance.Acceptsyour parser reads such documentsthe grammar’s verdict decides
    stance.Refusesyour parser rejects them on purposethe case expects a rejection
    stance.Eitheryour parser does not guarantee either answerthe case is not scored
    stance.Undeclaredno position (the zero value)the case is not scored

Find the positions by measuring your parser, not by reading its documentation. jsoncorpus.DefaultLexer was built that way, and two of its positions differed from what its authors expected.

Check the vocabulary first

Before you score anything, check that your table covers every tag the corpus uses:

if unknown := header.Unknown(stdlib.Speaks.Tags()); len(unknown) > 0 {
	return fmt.Errorf("the corpus uses tags this table does not know: %v", unknown)
}

A tag missing from your table counts as Undeclared, so every case carrying it becomes Undecided. Without this check, a newer corpus with a new tag would score fewer of your cases and give no warning.

Score every case

Convert each suite.Case to a stance.Doc, ask the table for the expected outcome, and compare it with what your parser does:

for _, c := range cases {
	tags := make([]stance.Tag, len(c.Tags))
	for i, tag := range c.Tags {
		tags[i] = stance.Tag(tag)
	}

	want, why := stdlib.Expect(stance.Doc{
		Name:       c.Name,
		Src:        c.Src,
		WellFormed: c.WellFormed,
		Opaque:     c.Opaque,
		Tags:       tags,
		VerdictAt:  suite.StageOf(c.VerdictAt),
	})
	if want == stance.Undecided {
		continue
	}

	accepted := json.Valid(c.Src)
	if accepted != (want == stance.Accept) {
		fmt.Printf("%s: want %v, got accepted=%v (%s)\n", c.Name, want, accepted, why)
	}
}

With the table above, json.Valid has no disagreement with the compact corpus.

Read the outcome

Table.Expect returns one of three outcomes, and a reason:

  • stance.Accept: a conforming parser with your positions reads the document.
  • stance.Reject: it refuses the document.
  • stance.Undecided: the case tells nothing about your parser. Skip it, and do not count it as a pass.

A case is Undecided when it carries a tag you did not declare or declared as Either, when the grammar’s acceptance does not reach the stage your parser stops at, or when the bytes are opaque to the oracle. With the table above, every Undecided case is opaque: its bytes are not valid UTF-8, json.Valid accepts some such documents, and the oracle cannot say what they denote. The reason string names the cause:

encoding/not-utf8: encoding/json Valid tolerates this, and nothing here can say what the bytes denote
without the decoder that would read them

Score several modes

A parser with a strict mode and a lenient mode needs two tables, and one corpus. Copy the table, change the positions that differ, and run the loop once per mode.

Select a subset

Each case lists the constructs it contains in Features. To run only part of a corpus, filter the stance.Doc values with stance.With or stance.Without. Features never change the expected outcome.

Keep your results in your repository

This module does not ship a test harness or a record of known failures. Keep the scoring loop, your tables and your list of known disagreements in your own repository, next to your parser.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Fuzz and property tests in Go

Scoring a parser against a corpus checks the cases the corpus holds. A fuzz target and a property test go past them. The fuzzer mutates the corpus documents, and yamlgen draws new documents for rapid. In both, the oracle gives the verdict on any document, so a test can check documents nobody wrote down.

The examples below test go-openapi/go-yaml. Replace yaml.Unmarshal with your parser’s entry point.

Install

go get github.com/go-openapi/conformance-suites
go get github.com/go-openapi/conformance-suites/yaml/corpus   # the embedded YAML corpus, 1.6 MB
go get github.com/go-openapi/conformance-suites/yaml/yamlgen  # the YAML generator, which requires rapid

Each is a module of its own, so a test requires only what it uses.

Seed a fuzz target

Add every corpus document as a seed. The corpus already covers the grammar, so the fuzzer starts there and spends its time on combinations nobody generated.

import (
	"testing"

	yamlcorpus "github.com/go-openapi/conformance-suites/yaml"
	yamlembed "github.com/go-openapi/conformance-suites/yaml/corpus"
	"github.com/go-openapi/go-yaml"
)

func FuzzUnmarshal(f *testing.F) {
	_, cases, err := yamlembed.CompactSuite()
	if err != nil {
		f.Fatal(err)
	}
	for _, c := range cases {
		f.Add(c.Src)
	}

	f.Fuzz(func(t *testing.T, src []byte) {
		var v any
		err := yaml.Unmarshal(src, &v)
		if err == nil && !yamlcorpus.Stream(src).OK {
			t.Errorf("accepted a document the YAML 1.2 grammar rejects:\n%q", src)
		}
	})
}

The check runs in one direction only. A parser that accepts a document the grammar rejects has a defect, unless you declare that leniency. A parser that refuses a document the grammar accepts may be right: the specification sets rules beyond the grammar, such as unique keys, and your parser takes positions on the questions it leaves open. To check that direction too, give each document a verdict with your stance.Table, as Score a parser does for the corpus cases.

go test without -fuzz runs each seed once: 25,175 distinct documents, about 6 seconds with go-yaml. With -fuzz, Go first measures the coverage of every seed, which takes about a minute before the fuzzer starts mutating. Seed a subset, such as the refused cases, to start sooner.

go-yaml’s own fuzz_test.go adds the YAML Test Suite and the inputs reduced from past bug reports to the same seeds.

JSON

RFC 8259 leaves little to the implementation, so a JSON fuzz target can compare verdicts in both directions:

import (
	"encoding/json"
	"testing"
	"unicode/utf8"

	jsoncorpus "github.com/go-openapi/conformance-suites/json"
)

func FuzzValid(f *testing.F) {
	_, cases, err := jsoncorpus.CompactSuite()
	if err != nil {
		f.Fatal(err)
	}
	for _, c := range cases {
		f.Add(c.Src)
	}

	f.Fuzz(func(t *testing.T, src []byte) {
		if !utf8.Valid(src) {
			return // json.Valid does not check UTF-8: the corpus tags this encoding/not-utf8
		}
		if got, want := json.Valid(src), jsoncorpus.Text(src).OK; got != want {
			t.Errorf("json.Valid says %v, RFC 8259 says %v:\n%q", got, want, src)
		}
	})
}

The JSON corpus is embedded in the root module, so this needs no other module.

Draw documents with rapid

yamlgen.Values draws what a document means and yamlgen.Styles draws how to write it. yamlgen.Emit writes a value in a style, and every document it writes is valid YAML 1.2. Two properties follow, and neither needs an expected value.

Every style reads the same

Write one value in two styles. A parser must read both documents as the same value.

import (
	"bytes"
	"testing"

	"github.com/go-openapi/conformance-suites/yaml/yamlgen"
	"github.com/go-openapi/go-yaml"
	"pgregory.net/rapid"
)

func TestEveryStyleReadsTheSame(t *testing.T) {
	rapid.Check(t, func(rt *rapid.T) {
		value := yamlgen.Values().Draw(rt, "value")
		sa, sb := yamlgen.Styles().Draw(rt, "style a"), yamlgen.Styles().Draw(rt, "style b")
		if sa.Version != "" || sb.Version != "" {
			return // "%YAML 1.1" changes what some spellings mean
		}
		a, b := yamlgen.Emit(value, sa), yamlgen.Emit(value, sb)

		var va, vb any
		ea, eb := yaml.Unmarshal([]byte(a), &va), yaml.Unmarshal([]byte(b), &vb)
		switch {
		case ea != nil && eb != nil:
			return // the parser refuses this value in any style: a position, not a presentation defect
		case ea != nil || eb != nil:
			rt.Fatalf("one style refused:\n%s\nerror: %v\n\nthe other:\n%s\nerror: %v", a, ea, b, eb)
		}

		// Compare what the parser writes back: one value has one canonical form.
		ca, _ := yaml.Marshal(va)
		cb, _ := yaml.Marshal(vb)
		if !bytes.Equal(ca, cb) {
			rt.Fatalf("one value, two readings:\n%s\nreads as\n%s\n%s\nreads as\n%s", a, ca, b, cb)
		}
	})
}

Three choices keep this property free of false failures:

  • A style that declares %YAML 1.1 is skipped. Under YAML 1.1, << is a merge key and some plain spellings resolve to other types, so the two documents can mean different things.
  • A value that both styles fail to read is skipped. go-yaml, for example, refuses a mapping as a key when it reads into any. That is a position the parser takes, and it does not depend on the style.
  • The two readings are compared through yaml.Marshal. Comparing Go values directly fails on NaN, and printing them shows the addresses of pointers such as *big.Float.

No broken document is accepted

yamlgen.Mutate breaks a valid document. Many mutations leave a document that is still valid YAML, so ask the oracle first, and keep only the documents it rejects.

import (
	"testing"

	yamlcorpus "github.com/go-openapi/conformance-suites/yaml"
	"github.com/go-openapi/conformance-suites/yaml/yamlgen"
	"github.com/go-openapi/go-yaml"
	"pgregory.net/rapid"
)

func TestNoMutantIsAccepted(t *testing.T) {
	rapid.Check(t, func(rt *rapid.T) {
		src := yamlgen.Emit(yamlgen.Values().Draw(rt, "value"), yamlgen.Styles().Draw(rt, "style"))
		mutant, how := yamlgen.Mutate(rt, src)
		if yamlcorpus.Stream([]byte(mutant)).OK {
			return // still YAML: the mutation broke nothing
		}

		var v any
		if err := yaml.Unmarshal([]byte(mutant), &v); err == nil {
			rt.Fatalf("accepted a document the YAML 1.2 grammar rejects (%s):\n%q", how, mutant)
		}
	})
}

how names the mutation, such as a-document-marker-inside, so a failure tells you what kind of break the parser missed.

When a property fails

rapid shrinks the drawn value and style to a small failing case, and prints a -rapid.failfile flag that replays it. Raise the number of draws with -rapid.checks: the default is 100, and the rarer shapes appear only after thousands of draws.

go-yaml’s tests go further. They compare each document with the value the generator meant (yamlgen.Write returns it as Written.Means), and they keep a ledger of known divergences (yamlgen.Divergence), so that a known defect does not stop the run and a fixed one is noticed.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Concepts

The concepts that ship with a document in our corpus: coverage, oracle, tags and stances.

  • A recognizer compiled from the grammar each specification publishes, used to label every generated document.
  • Why a case stores the grammar’s verdict and a list of tags, and how a stance turns them into an expected outcome.
  • How the builder decides which generated documents to keep, and why the compact corpus keeps 16 refusals per signature.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Subsections of Concepts

The oracle

Every case in a corpus carries wellFormed, the verdict of an oracle: a recognizer compiled from the grammar the specification publishes. This page explains why the corpus needs one, where the grammars come from, and what the oracle returns.

Why a generated corpus needs an oracle

The generator writes a valid document, then breaks it with a mutation: it deletes a byte, swaps two, truncates the text. The generator cannot tell whether the result is still valid. In JSON, most mutations break the document. In YAML, most do not: a: b with a byte deleted is a:b, a plain scalar, and still valid YAML. So each document needs a label from something that knows the language.

Why not an existing parser

A corpus labelled by a parser stores that parser’s answers. Every other parser would then be scored against its bugs, and the parser itself would always score perfectly. The oracle instead reads the grammar that the specification publishes, so a disagreement between a parser and the corpus points at one of two documents: the parser or the grammar.

The oracle also separates two faults that a round trip cannot. When parse(render(value)) fails, the renderer may have written invalid text, or the parser may have refused valid text. Asking the oracle about render(value) tells which.

Where the grammars come from

languagegrammar filesourceproductions
YAML 1.2yaml/testdata/yaml-spec-1.2.jsonpublished by yaml/yaml-grammar211
JSONjson/testdata/rfc8259.jsontranscribed from RFC 8259 into the same format33

The YAML grammar is a parameterized PEG. Its rules take up to four arguments: the indentation n, the extra indentation m, the context c (such as block-in or flow-key) and the chomping t. Its notation adds ordered choice, lookahead in both directions, lookbehind and character-set subtraction. JSON needs none of the parameters, but uses the same format, so one compiler serves both.

What the oracle returns

res := yamlcorpus.Stream(src) // or jsoncorpus.Text(src)
res.OK                        // whether the whole input matches the grammar

Result holds the verdict and two counters, Steps and Hits, which measure the work done. The oracle builds no tree, emits no events and returns no error message. It only has to be right, so it skips everything a parser spends its time on.

functionquestion
yamlcorpus.Streamis src a valid YAML 1.2 stream (l-yaml-stream, from block-in)?
yamlcorpus.FlowNodeis src exactly one flow node (ns-flow-node, from flow-out)?
jsoncorpus.Textis src exactly one JSON text?
NewRecognizer(hint)a reusable oracle, for a caller that checks documents in a loop

The verdict covers syntax only. YAML sets rules the grammar cannot express, such as an alias naming an anchor that occurs earlier, and a parser that composes the document must check them too. The corpus records how far the verdict reaches in verdictAt: see Tags and stances.

Patches to the YAML grammar

The YAML specification states some rules in its prose and leaves them out of the grammar file. Compiling the file as published would accept documents YAML forbids, or refuse documents it allows. So yamlcorpus applies 13 patches before compiling. Each names the rule it rewrites and the reason:

rulethe prose the grammar file leaves out
s-l+block-indentedthe extra indentation a compact collection detects is not written down
c-b-block-headerthe two block header indicators may be written in either order
c-b-block-headera block scalar’s header ends at the end of its line
c-indentation-indicatorzero is not a legal indentation indicator
ns-flow-map-entry, ns-flow-pair, c-l-block-map-explicit-keya ? with no space after it opens a plain scalar, not an explicit key
c-directives-enda directives-end marker is a line holding only the three dashes
ns-flow-yaml-nodea flow collection carrying properties is still a flow node
ns-flow-map-implicit-entrya JSON-like key carrying properties may take a value adjacent to its :
s-l+block-collectionproperties belong to the collection only if the line ends after them
ns-reserved-directiveYAML and TAG name the two directives the spec defines, so neither names a reserved one

Most patches add the same missing check: the specification writes an indicator character into the grammar, then constrains what may follow it in the text around the production.

None of the patches follows what a parser does. Each one rests on the specification’s text, and each one checks the shape of the rule it rewrites: if a newer grammar file fixes or moves the rule, the compile fails and names the patch.

JSON needs no patch. RFC 8259’s grammar runs as written.

Calibration

A corpus stores the oracle’s verdicts, so an oracle wrong on one document puts a false accusation into every corpus built from it. Two tests score the oracles against the hand-written suites before any corpus is built:

suitemust acceptmust rejectthe oracle
YAML Test Suite (TestRecognizerAgreesWithTheYAMLTestSuite)29994agrees on all but 2
JSONTestSuite (TestRecognizerAgreesWithJSONTestSuite)95188agrees on all

The two YAML departures

The oracle accepts two fixtures that the YAML Test Suite marks as errors:

# duplicate-yaml-directive
%YAML 1.2
%YAML 1.2
---
# tag-shorthand-used-in-documents-but-only-defined-in-the-first
%TAG !prefix! tag:example.com,2011:
--- !prefix!A
a: b
--- !prefix!B
c: d
--- !prefix!C
e: f

The suite is right about both. Section 6.8.1 makes a second %YAML directive for the same document an error. Section 6.8.2.2 scopes a %TAG directive to the document that follows it, so !prefix! is undefined in the second and third documents.

The grammar cannot express either rule:

  • l-directive-document takes one or more l-directive, and each matches one directive alone. Nothing in a production counts how many %YAML lines came before.
  • c-ns-shorthand-tag is a c-tag-handle followed by tag characters. It matches the shape of !prefix! and never asks whether a %TAG directive declared it. Checking that takes a table of the handles each document declares, and a grammar keeps no table.

So the oracle accepts both documents, as the grammar does. A patch cannot fix this, because each rule needs state that lives outside any production. TestRecognizerAgreesWithTheYAMLTestSuite lists the two fixtures by name, with the reason. The test fails if either one starts to agree, so the list cannot go stale.

The corpus states both rules as tags with a settled outcome, instead of as verdicts:

tagstagesettled
directive/yaml-repeatedcomposereject, section 6.8.1
directive/handle-out-of-scopecomposereject, section 6.8.2.2

A case carrying either tag keeps the grammar’s wellFormed: true, and Table.Expect turns the settled rule into an expected rejection. See Settled rules.

The YAML Test Suite has one flaw here: its error file marks a broken syntax and a broken rule the same way. A parser that checks only syntax cannot tell which of its failures on the suite are real defects. The corpus keeps the two apart: wellFormed holds the grammar’s verdict, and the tag holds the rule and the stage it belongs to.

How it runs

grammar.Compile walks the grammar file once and builds a tree of Go closures. Running closures costs two orders of magnitude less than interpreting the decoded file at every step, and a corpus build calls the oracle hundreds of thousands of times.

The recognizer memoizes the result of a rule at a position. Without it, nested flow collections take exponential time: twenty nested sequences take 115 million steps and five seconds. With it, the time is linear, at about twice the cost on documents that never backtrack.

The package documentation of internal/grammar describes the rest:

  • how a block scalar’s header passes m and t to the rule after it;
  • how a block collection’s indentation is measured from its first line;
  • why a failed alternative costs nothing to undo.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Tags and stances

A case does not say “must accept” or “must reject”. It stores the grammar’s verdict and the list of questions the document raises that the specification leaves open. A stance, declared by each parser, turns the two into an expected outcome when the corpus is replayed.

Why a corpus cannot store “must accept”

Every specification worth testing against leaves some questions to the implementation:

  • RFC 8259 lets a parser limit the range and precision of numbers, and calls the meaning of an unpaired surrogate escape unpredictable.
  • YAML 1.2 admits UTF-8, UTF-16 and UTF-32, and a library may support only one of them.

A corpus that stored “this document must be accepted” would store one parser’s choice as if it were the language, and would mark a conforming parser wrong for making another. So a case stores what the grammar says, and names the open questions with tags.

Tags and features

A tag (stance.Tag) names a question the language leaves open: number/out-of-range, encoding/bom, anchor/cyclic-meaning. A case lists the tags its document carries. A tag gates scoring: a parser that has no position on a tag is not scored on the cases carrying it.

A feature (stance.Feature) names a construct the document contains: a flow collection, a CRLF line break, an anchor. Features never change the expected outcome. Use them to select a subset of the corpus with stance.With and stance.Without, and to report what a failing document holds.

To decide which one a new label is, ask whether a conforming parser could refuse the construct, or read it differently. If it could, the label is a tag. If it could not, it is a feature.

Tags lists every tag.

Stands

A stance.Table records a parser’s stand on each tag:

standmeaning
Acceptsthe parser reads such documents, and the grammar’s verdict decides
Refusesthe parser rejects them on purpose, so the case expects a rejection
Eitherthe parser does not guarantee either answer, so the case is not scored
Undeclaredno position, the zero value: the case is not scored

Undeclared is not scored on purpose. A table that leaves a tag out gives no free pass on the cases carrying it. Call Header.Unknown to find the tags a corpus uses that your table does not know.

Outcomes

Table.Expect returns an outcome and the reason for it:

  • Accept: a conforming parser with these stands reads the document.
  • Reject: it refuses the document.
  • Undecided: the case tells nothing about this parser. Skip it, and do not count it as a pass.

Read a corpus lists the steps Table.Expect takes, for readers without Go.

Stages

“Valid” is not one question. A document can be well formed and still not resolve, or resolve and still not fit the model a program loads it into. The YAML specification names the steps, and they apply to JSON too:

stagewhat a parser does
Parsereads the characters into a serialization: syntax
Composebuilds the representation: resolves aliases, collects mapping keys
Constructbuilds native values: numbers, strings, maps

Each tag has the stage at which its question first arises, in the grammar’s vocabulary and in the header’s vocabulary. number/out-of-range arises at Construct, because nothing before construction has a numeric type.

Table.At is how far a parser takes a document, and it is a floor. A parser that stops at Parse is not asked about a tag that arises at Construct. A parser that notices a parse question later, say while it builds a string, still answers it.

Encoding is not a stage. What a run of bytes denotes is settled before parsing starts.

How far the verdict reaches

wellFormed is the grammar’s verdict at Parse. A refusal holds at every stage: a document that does not parse does not compose or construct either. An acceptance does not: a document can parse and still fail to compose, as when it uses an alias to an anchor that never occurs.

So a case records verdictAt, the last stage at which an acceptance by the grammar is evidence. A parser that goes further than verdictAt is not scored on the case’s acceptance. An absent verdictAt means Parse, the least a case can claim.

Settled rules

Some questions the grammar cannot express are settled by the specification all the same. YAML says an alias must refer to an anchor that occurs earlier in the document: a parser that reads an undefined alias is wrong, whatever its stance.

A stance.Rule records such a requirement: the tag, the clause that settles it, and the outcome it fixes. The header’s tag spec carries the same facts in settled and because. Table.Requires holds a language’s rules, and Table.Expect checks them before the stands:

  • A rule that fixes Reject makes the case expect a rejection, whatever the table’s stand.
  • A rule that fixes Accept says the construct is legal. The grammar still decides whether the document is.
  • A table can decline a rule with Either, when the parser cannot check it at all: a parser that never resolves aliases cannot check a rule about them. The case is then not scored. A table cannot turn a settled rejection into an acceptance.

Rules.Contradicted names the settled rules a table marks Accepts. Such an entry is a mistake, most likely a tag copied into the wrong table, and the function reports it so you can delete it.

Opaque bytes

The oracle reads UTF-8. A case is opaque when its bytes are not valid UTF-8, even after the normalization the grammar allows. The grammar’s verdict then says nothing about a parser that decodes those bytes in some other way, as UTF-16 or with replacement characters.

So for a parser that Accepts the tag explaining the bytes, usually encoding/not-utf8, an opaque case is Undecided. A parser that Refuses the tag still expects a rejection: refusing does not depend on what the bytes denote.

Two examples

Each example takes one case from a compact corpus and runs Table.Expect on it with several tables. The outcomes and reasons are copied from a run; each reason drops the table name it starts with.

JSON: a lone surrogate

The case shape/value/lone high surrogate, from the JSON compact corpus:

{
  "name": "shape/value/lone high surrogate",
  "src": "WyJcdUQ4MzQiXQ==",
  "wellFormed": true,
  "tags": ["string/lone-surrogate"],
  "verdictAt": "construct"
}

src is ["\uD834"]: an array holding a string whose only escape is the first half of a surrogate pair. The grammar accepts it, because RFC 8259’s grammar allows any \u escape. The RFC calls the result unpredictable, so the case carries string/lone-surrogate, an open tag.

tablestand on string/lone-surrogateoutcomereason
jsoncorpus.DefaultLexerRefusesRejectrefuses this on purpose
encoding/json Valid, from Score a parserAcceptsAcceptthe grammar accepts it and no property this parser refuses is present
a table that declares EitherEitherUndecideddeclines to guarantee this
a table that leaves the tag outUndeclaredUndecidedhas not ruled on this

DefaultLexer and encoding/json give opposite answers, and both conform. The case scores each against what it declares.

YAML: a merge key

The case shape/merge/a merge from an anchored mapping, from the YAML compact corpus:

{
  "name": "shape/merge/a merge from an anchored mapping",
  "src": "YmFzZTogJmIge2E6IDF9CmQ6CiAgPDw6ICpiCiAgYzogMgo=",
  "wellFormed": true,
  "tags": ["merge/key"],
  "verdictAt": "construct"
}

src is:

base: &b {a: 1}
d:
  <<: *b
  c: 2

YAML 1.1 reads << as a merge key, so d holds a: 1 and c: 2. YAML 1.2 dropped merge keys from the core schema, and many parsers still apply them. The question arises when the parser builds native values, so merge/key is placed at Construct. It is an open tag: no rule settles it.

Each table below sets Speaks: yamlbuild.Vocabulary() and Requires: yamlbuild.AllRules():

tableAtstand on merge/keyoutcomereason
applies merge keysConstructAcceptsAcceptthe grammar accepts it and no property this parser refuses is present
refuses merge keysConstructRefusesRejectrefuses this on purpose
does not guarantee eitherConstructEitherUndecideddeclines to guarantee this
no positionConstructUndeclaredUndecidedhas not ruled on this
refuses merge keys, stops at composingComposeRefusesAcceptthe grammar accepts it and no property this parser refuses is present
a parser onlyParseUndeclaredAcceptthe grammar accepts it and no property this parser refuses is present

The last two rows show the stage floor. merge/key arises at Construct, past where these two tables stop, so Table.Expect skips the tag and the grammar’s verdict decides. A parser that never builds native values never meets the merge question, so its stand on merge/key does not matter.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Coverage and selection

A build draws far more documents than a corpus can hold. This page explains what the oracle records while it reads a document, and how the builder uses that record to choose the documents to keep.

What the oracle records

Given a Coverage vector, the oracle counts each production it enters while it reads a document. A bucket is not the production alone:

  • YAML: the production, the context it was entered in (block-in, flow-key, …), and the indentation n and m, each reduced to nine classes.
  • JSON: the production. JSON has no context and no indentation.

The context is part of the bucket because the same rule decides differently in block-in and in flow-key. The indentation is part of it because two documents that differ only in how far they are indented once produced the same record, and the builder kept one of them.

Each bucket counts attempts and successes apart, so a backtracked attempt still counts as an entry.

rec := yamlcorpus.NewRecognizer(4096)
cov := yamlcorpus.NewCoverage()
rec.Cover(cov)

for _, doc := range docs {
	rec.Stream(doc)
}

Reach computes the buckets that can be entered at all, from a start production in a context. From a YAML stream, 605 production-by-context buckets are reachable, and the compact corpus enters every one. A test fails if a document enters a bucket Reach declares unreachable.

Signatures

A document’s signature is a digest of the set of buckets it entered. Two documents with one signature took the same route through the grammar. For a refused document, the route is close to a statement of how the document is wrong.

The signature that put a case in the corpus is stored in origin.signature. Bucket numbers change when the grammar changes, so the corpus stores digests and documents, never vectors.

How a build keeps a document

Generate(seed, documents, mutantsEach) draws valid documents and breaks each one mutantsEach times. The builder then reads each document with the oracle and keeps it if any of these holds:

  1. it enters a bucket no kept document has entered;
  2. its signature has fewer than PerSignature kept documents;
  3. it holds a combination of constructs no kept document holds, such as a tab, an escape or a line break style (in JSON, this applies to valid documents only);
  4. in YAML, it carries a meaning.

The construct set catches what the route cannot. The compact YAML corpus enters every reachable bucket, so a new document rarely reaches a new one, and a document holding a tab takes the same route as one holding a space.

A document with a meaning is never dropped. Two documents can take the same route and denote different values: they are one test for a recognizer and two for a decoder. A mutant carries no meaning, because nobody knows what it denotes, so the quota applies to it.

The enumerated shapes go in before any drawn document and are never dropped: the JSON encoding and value shapes, and the YAML families such as anchor patterns and schema scalars. No coverage signal points at them. A byte order mark appears in no grammar production, and an alias enters the same productions whether its anchor exists or not.

Tiers

A tier is a Build recipe. The three tiers draw from the same seed and differ in how many documents they draw and how many they keep:

tierJSONYAML
compactCompact(): 8,000 documents, 24 mutants each, up to 16 per signature: 3921 casesCompact(): 3,000 documents, 16 mutants each, up to 16 per signature: 28279 cases
extended40,000 documents, 24 mutants each, up to 16 per signature: 11982 cases15,000 documents, 16 mutants each, up to 16 per signature: 112578 cases, 6.8 MB
fullFull(): the compact draw, every document kept: 144396 casesFull(): 6,000 documents, 12 mutants each, every document kept
  • Compact lives in the repository, and the Go modules embed it. Every test run rebuilds it and compares the result with the stored file.
  • Extended draws five times the compact documents and keeps the same quota, so it reaches the shapes the generator draws rarely. The quota caps the refused documents, so five times the documents gives about three times the JSON cases and four times the YAML ones. Run against the YAML extended tier on 2026-11-23, go-yaml showed seven candidate defects that the compact tier had missed. Extended is written as a Build literal for now, not as a function; it is meant to ship with each release.
  • Full drops nothing, valid documents included. No build calls Full() today.
err := yamlbuild.Build{Tier: "extended", Seed: 1, Documents: 15000, MutantsEach: 16, PerSignature: 16}.Write(w)

A build reads no clock and calls no parser, so the same recipe writes the same bytes every time.

Why sixteen per signature

A signature is how the oracle sees a document. Keeping one document per signature throws away everything two documents differ by that the oracle cannot see, and parsers fail in exactly those places.

The quota was set by replaying each build through go-yaml and counting the distinct error messages it produced:

documents kept per signature141632
distinct messages14192223

Going from 16 to 32 found one more message and cost 37 KB. Drawing more documents found more than raising the quota did, because most messages appear in about one document in twenty thousand. So the compact build keeps 16 per signature and draws more documents.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Meanings and readings

A verdict says whether a parser must read a document. A meaning says what the parser must read it as. The YAML corpus carries a meaning for 2864 of its 28279 compact cases. The JSON corpus carries none.

When a case carries a meaning

The generator draws a value first and writes it as YAML second, so it knows what each document it writes means. The hand-written families, such as the anchor and schema shapes, state theirs too. A case carries no meaning when:

  • the grammar refuses the document: a refused document denotes nothing;
  • the document is a mutant: nobody knows what a broken document denotes, even when it is still valid;
  • the generator declines to say. One shape does this, under %YAML 1.1: the same text written plain in one place and quoted in another, where the generator cannot tell which occurrence resolved to a boolean.

The fields

A meaning is stored in the case, as a JSON object:

fieldholds
underthe reading that gives this answer, such as yaml-1.2-core
jsonthe value, written as JSON
cyclictrue when the value holds a cycle, and then json is absent

Compare json as a JSON value, not as text: the writer compacts the whitespace, and a reader that decodes numbers into float64 rounds those it cannot hold.

A cyclic value, such as recursive: &x [ *x ], has no JSON form. The compact corpus holds 4 such cases. A parser that returns a value it can write as JSON for one of them has replaced the cycle with something else.

Readings

A plain scalar carries no tag, so a resolution step outside the grammar decides what it denotes. YAML defines several. A reading names the one used:

readingresolution
yaml-1.2-coreYAML 1.2’s core schema, the specification’s default
yaml-1.1YAML 1.1’s types, still common: yes is a boolean and 0777 is octal

The header lists the readings the corpus weighed in readings. The JSON and failsafe schemas of YAML 1.2 are not weighed. The failsafe schema reads every scalar as a string. The JSON schema may refuse a scalar that matches none of its own productions, which would be a verdict and not a value, and the corpus leaves that question open.

One meaning, or one per reading

Most documents mean the same under every reading. Such a case carries meaning alone.

Where the readings disagree, the case also carries meanings, with one entry per reading that has an answer. The core answer appears in both fields, so a consumer can look in one place. The compact corpus holds 334 such cases:

{
  "name": "shape/schema/0777",
  "src": "azogMDc3Nwo=",
  "wellFormed": true,
  "tags": ["schema/int-octal-legacy"],
  "meaning": {"under": "yaml-1.2-core", "json": {"k": 777}},
  "meanings": [
    {"under": "yaml-1.2-core", "json": {"k": 777}},
    {"under": "yaml-1.1", "json": {"k": 511}}
  ]
}

src is k: 0777 in base64. When meanings is present and has no entry for a reading, that reading has no answer for the document: YAML 1.1, for example, has no reading of a 0o513 integer under a !!int tag.

Pick the meaning for your parser

Declare the reading your parser implements in stance.Table.Reads, then ask the header:

table := stance.Table{Reads: "yaml-1.1" /* ... */}

if m, ok := header.MeaningFor(c, table.Reads); ok {
	// compare your parser's value with m.JSON, or check m.Cyclic
}

Header.MeaningFor returns one of three answers:

  • the case lists an answer under the reading: it returns that answer;
  • the case lists none, and the corpus weighed the reading: the readings agree, so it returns meaning;
  • the corpus never weighed the reading: it returns false, and the case says nothing about your values.

An empty Reads asks for the corpus default, the answer in meaning.

Without the header’s list, the second and third answers would look the same. A parser reading the failsafe schema would be handed the integer for k: 1, and marked wrong for reading the string "1".

Without Go, the same steps take a few lines: look for your reading in meanings; if meanings is absent and your reading is in the header’s readings, use meaning; otherwise skip the value.

A meaning never changes a verdict

Table.Expect does not read Table.Reads. k: 0777 is a valid document under every reading; the readings disagree only on what it denotes. So a parser on another reading is scored on the verdict as usual, and on the value only where the corpus states an answer for its reading.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Suites

Each suite has its grammar, its generator, its tag vocabulary and its corpus.

  • RFC 8259, compiled with no patches: the generator, the mutations, the tags, and DefaultLexer.
  • YAML 1.2, patched for the rules the spec states in prose: the generator, the mutations, the tags and features, the readings, and the parsers the corpus is checked against.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Subsections of Suites

JSON

The JSON suite tests whether a parser accepts exactly the documents RFC 8259 admits, and holds it to the positions it declares on the questions the RFC leaves open. The package is jsoncorpus, in the root module.

The grammar

jsoncorpus.JSON is the grammar of RFC 8259, compiled from json/testdata/rfc8259.json with no patches: every production runs as the RFC writes it. It has 33 rules. jsoncorpus.Text checks one document against it:

ok := jsoncorpus.Text(src).OK

Calibration

Before the grammar decides a single case, TestRecognizerAgreesWithJSONTestSuite scores it against the vendored copy of Nicolas Seriot’s JSONTestSuite:

filescountthe grammar
y_, must accept95accepts every one
n_, must reject188refuses every one
i_, implementation-defined35accepts 21; the test records them and asserts nothing

A corpus stores the grammar’s verdicts, so a grammar wrong on one document would put a false accusation into every corpus built from it.

The generator

jsoncorpus.Generate(seed, documents, mutantsEach) draws documents and breaks each one:

  • RandomValue draws a value tree, and RandomStyle draws how to write it: indentation and spacing, the whitespace around the top value, and which characters are escaped.
  • Emit writes the value in that style.
  • Mutate applies one of 8 mutations to the bytes: delete a byte, delete a run, duplicate a byte, swap two neighbors, truncate, substitute a byte the grammar knows, insert a byte the grammar knows, substitute an arbitrary byte.

The grammar then gives each document and each mutant its verdict. A Build keeps the cases that bring a coverage signature nothing has brought yet: Compact() keeps up to 16 per signature, and Full() keeps every document. Coverage explains signatures.

The generator draws only values whose meaning it knows, so two kinds of case are written by hand:

  • ValueShapes writes the documents whose meaning RFC 8259 leaves open, each with its tag: duplicate names and lone surrogate escapes.
  • EncodingShapes writes every byte order mark in every position it can occupy.

The census

TestTheGeneratedCorpusIsWiderThanTheSuite checks that every construct a valid JSONTestSuite document holds, a case of the compact corpus holds too. It counts 40 constructs, from a top-level scalar to an escaped form feed, listed by jsoncorpus.Constructs. None is missing. Grammar coverage cannot make this check: the suite and the corpus both enter every production.

Normalization

jsoncorpus.Normalize removes a leading UTF-8 byte order mark, and nothing else. RFC 8259 section 8.1 lets a parser ignore the mark, and the bytes after it are unchanged. A case’s wellFormed is the grammar’s verdict on the normalized bytes.

Ill-formed UTF-8 and UTF-16 are not normalized. Reading them takes a decoder and a policy for what does not decode, and the suite would be grading a parser against a policy of its own.

Tags

The JSON vocabulary has 8 tags. jsoncorpus.Vocabulary places each at a stage:

tagstagethe open question
encoding/bom, encoding/not-utf8, encoding/utf16, encoding/utf32parsewhat the bytes denote
string/lone-surrogateparsewhat an unpaired \uXXXX escape means; RFC 8259 section 8.2 calls it unpredictable
structure/deep-nestingparsehow deep a parser nests before it gives up
object/duplicate-namecomposewhich member of a repeated name wins; RFC 8259 section 4 calls it unpredictable
number/out-of-rangeconstructwhat a number past float64 becomes; RFC 8259 section 6 lets a parser limit range and precision

RFC 8259 settles none of them. Tags gives the full description of each.

DefaultLexer

jsoncorpus.DefaultLexer is the stance of the default lexer of github.com/go-openapi/core/json:

tagstand
encoding/bomAccepts
encoding/not-utf8, encoding/utf16, encoding/utf32Refuses
string/lone-surrogateRefuses
structure/deep-nestingAccepts

Its At is Parse: the lexer returns a number’s text and converts nothing, so it never reaches the stage where a number can be out of range, and the table takes no position on number/out-of-range.

The positions were measured, by running the lexer over the suite’s implementation-defined cases. Two of them differed from what its authors expected:

  • the lexer tolerates a byte order mark, though it still refuses a mark with no document after it;
  • it refuses a lone surrogate escape, which is stricter than the grammar.

What the suite leaves out

  • Resource limits. structure/deep-nesting marks a document nested more than 128 levels deep, the depth where nesting stops being a shape and becomes a question of a parser’s limits. The generator stays well below it on purpose, so no case carries the tag: the suite tests what a parser reads, not the budget that stops it on hostile input.
  • Meanings. A JSON case carries no meaning: the corpus says whether a parser should accept a document, not what value it should read.
  • Features. A JSON case carries no features, so a subset cannot be selected by construct.
  • Other parsers. The YAML suite is checked against five parsers in the consensus module. The JSON suite is checked against JSONTestSuite only.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

YAML

The YAML suite tests whether a parser accepts exactly the documents YAML 1.2 admits, holds it to the positions it declares on the questions the specification leaves open, and states what each valid document means.

packagemoduleholds
yamlcorpusgithub.com/go-openapi/conformance-suites (directory yaml/)the oracle
yamlgengithub.com/go-openapi/conformance-suites/yaml/yamlgenthe generator: values, styles, the emitter, mutations for property tests
yamlbuildthe same module, yaml/yamlgen/yamlbuildthe corpus builder and the tag vocabulary
yamlembedgithub.com/go-openapi/conformance-suites/yaml/corpusthe compact corpus, embedded: 1.6 MB, so it has a module of its own

The grammar

yamlcorpus.YAML is the grammar that yaml/yaml-grammar publishes, with 211 productions, compiled with 13 patches for rules the specification states only in prose. yamlcorpus.Stream checks one stream:

ok := yamlcorpus.Stream(src).OK

The oracle lists the patches, and the calibration against the YAML Test Suite: 299 fixtures that must be accepted and 94 that must be rejected, with 2 declared departures.

The generator

yamlgen draws a value first, then a way to write it:

  • Values draws a value tree: scalars of every core type, sequences, mappings, mappings keyed by collections, and anchors with aliases in about a quarter of the documents.
  • Styles draws a Style: block or flow, the indentation, the quoting, literal or folded scalars and their chomping, comments, line breaks, tags and how to spell them, number and time forms, escapes, directives, explicit keys, a byte order mark, and %YAML 1.1.
  • Emit writes the value in that style. Every document it writes is valid YAML 1.2.

The value comes first, so the builder knows what each valid document means: see Meanings.

yamlbuild.Generate draws through rapid’s Example, which produces a value from a seed, so a seed rebuilds the corpus byte for byte. Every test run rebuilds the compact corpus and compares it with the stored file, so a rapid upgrade that changes the draws fails the build.

Mutations

The builder breaks each document with one of 10 mutations: delete a byte, delete a run, duplicate a byte, swap two neighbors, truncate, substitute a byte, substitute an indicator, insert an indicator, indent a line further, outdent a line.

The byte mutations know nothing about YAML, on purpose: a mutation that knew the grammar would make only the errors someone already thought of. The two indentation mutations are the exception. A random byte rarely lands in the leading spaces of a line, and indentation is where parsers and this recognizer have had their bugs.

Most mutants are still valid YAML. The oracle sorts them, and the corpus keeps the ones that bring a new route through the grammar: see Coverage.

yamlgen.Mutate, used in property tests, is a separate set aimed at YAML’s structure: a tab in the indentation, a line moved sideways, a document marker inside a scalar. The corpus builder does not use it.

Rules broken on purpose

Some documents are valid by the grammar and still wrong, and a byte mutation almost never writes one. The builder writes them with 4 rewrites of a valid value, each with its tag:

rewritetag
alias renamed to nothinganchor/alias-undefined
a key repeatedkey/duplicate
a duplicate entry appendedkey/duplicate
a collection key written twicekey/duplicate

Enumerated shapes

131 cases are written by hand, named shape/<family>/<what>, and never dropped by the builder. No coverage signal points at them: an alias enters the same productions whether its anchor exists or not, and every plain scalar enters the same productions whatever it denotes. The families:

familycovers
anchoraliases undefined, forward, across documents and as keys; anchors redefined, unused or on an empty node; cycles
directiverepeated %YAML and %TAG, versions, reserved directives, handles out of scope
escapean escape of the last code point, and one past it
indentation, separationtabs between a property and its node, and tabs opening a block scalar’s content
keyduplicates, before and after resolution; keys that are booleans, null, floats, tagged, aliases or collections
merge<< keys: from an alias or a mapping written in place, a sequence of merges, overridden, quoted, alone
reachproductions the generator rarely reaches: explicit keys in flow, kept trailing breaks, more-indented folded lines
schemaplain scalars the YAML 1.1 and 1.2 schemas resolve differently: yes, 0777, 1_000
tagverbatim, local, non-specific and secondary tags; handles and percent escapes; tags whose content does not fit, such as !!int on a word; !!omap

Encoding

The oracle reads UTF-8. A document that starts with a byte order mark carries encoding/bom. A document whose bytes are not valid UTF-8, almost always a mutant, carries encoding/not-utf8 and is marked opaque: the compact corpus holds 1596 of them. The YAML generator writes no UTF-16 or UTF-32, so the corpus carries no tag for them.

Tags

The YAML vocabulary has 66 tags. The specification settles 11 of them as a rejection and 11 as an acceptance, and leaves 44 open:

familystagesthe questions
anchor/*parse, compose, constructundefined and forward aliases (settled: reject), aliases as keys and redefined anchors (settled: accept), cyclic values (open)
directive/*parse, composerepeated directives (settled: reject), a later minor version (open), reserved directives (settled: accept)
encoding/*parsea byte order mark, bytes that are not UTF-8
escape/*, indentation/*, separation/*parse, composeescapes past U+10FFFF (settled: reject), tabs
key/*parse, compose, constructduplicate keys (settled: reject), keys that are not strings or not scalars (open)
merge/*constructevery form of <<: YAML 1.2 dropped merge keys, and many parsers still apply them
representation/*, json/*constructvalues a native type may not hold: wide integers, out-of-range floats, binary, timestamps, ordered maps
schema/*constructplain scalars the schemas resolve differently
tag/*parse, compose, constructundeclared handles (settled: reject), verbatim and non-specific tags (settled: accept), tags on content that does not fit them (open)

Tags lists every tag with its stage, its settled outcome and its description.

Features

A YAML case also lists features: the constructs its document holds, from presentation/block-literal to node/anchor and value/merge-key. The header lists all 61. Features never change an expected outcome. Use them to select a subset of the corpus, or to see what a failing document holds:

gunzip -c yaml-compact.jsonl.gz | tail -n +2 | jq -c 'select(.features | index("presentation/block-folded"))'

Readings and meanings

2864 compact cases carry a meaning, and 334 carry one per reading, under yaml-1.2-core and yaml-1.1. Meanings explains how to pick the one that applies to your parser.

Other parsers

Two modules import real parsers. The root module imports none.

  • yaml/consensus runs five implementations over the corpus: the YAML 1.2 reference parser (Perl), libfyaml, YAMLStar, go.yaml.in/yaml/v3 and github.com/go-openapi/go-yaml. The consensus report shows where they agree with the corpus and with each other.
  • yaml/calibrate holds tests only. They check the generator and the corpus against go-openapi/go-yaml: that every emitted document parses, that every style of one value reads the same, and that the stated meanings are what a parser reads.

What the suite leaves out

  • The JSON and failsafe schemas. The corpus states meanings under two readings only; see Meanings.
  • Events and output. The YAML Test Suite stores a parser’s event stream (test.event) and a canonical rendering (out.yaml). The corpus stores neither: it states what a document means, not how a parser reports reading it.
  • UTF-16 and UTF-32 documents. See Encoding above.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Reference

Look things up here. The concepts behind each field are in Concepts.

  • Format 4: every field of the header and of a case, and the compatibility rules.
  • Every tag, its stage, and whether the specification settles it.
  • Five YAML parsers read the compact YAML corpus: where they agree with it, and with each other.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Subsections of Reference

File format

A corpus file holds one conformance suite: a header describing the suite, followed by its test cases. This page lists every field, with its type and when it may be absent. The reasons behind the fields are explained in Concepts.

Container

A corpus file is a gzip-compressed JSON Lines file, encoded in UTF-8.

  • Line 1 holds the header object.
  • Each following line holds one case object.
  • The test document in src is encoded in standard base64 with padding, because it often holds bytes that are not valid UTF-8 and cannot appear in a JSON string. Every other field is plain JSON.

The gzip header carries no modification time and no operating system, so two builds of the same corpus with the same Go toolchain produce identical files.

The Go reader accepts lines up to 8 MiB.

The header of the embedded JSON compact corpus:

{
  "format": 4,
  "grammar": "RFC 8259",
  "digest": "sha256:ae0322c3aeb0db880dc20a2a5984f4318d59469efe4c5e3b80de5f1314ac584c",
  "generator": "jsoncorpus/3",
  "seed": 1,
  "tier": "compact",
  "cases": 3921,
  "vocabulary": [
    { "tag": "encoding/bom", "stage": "parse" },
    { "tag": "encoding/not-utf8", "stage": "parse" },
    { "tag": "encoding/utf16", "stage": "parse" },
    { "tag": "encoding/utf32", "stage": "parse" },
    { "tag": "number/out-of-range", "stage": "construct" },
    { "tag": "object/duplicate-name", "stage": "compose" },
    { "tag": "string/lone-surrogate", "stage": "parse" }
  ]
}
fieldtypepresentcontent
formatintegeralwaysThe layout version, 4 for this page.
grammarstringalwaysThe name of the grammar behind the verdicts: RFC 8259, YAML 1.2.
digeststringalwayssha256: and the hex SHA-256 of the grammar file behind the verdicts.
generatorstringalwaysThe name and version of the generator that produced the documents: jsoncorpus/1.
seedintegeralwaysThe seed given to the generator.
tierstringalwayscompact for the small corpus embedded in the module, extended for the larger one with the same quota, full for the one that keeps every document.
casesintegeralwaysThe number of case lines after the header.
vocabularyarray of tag specsalwaysEvery tag used by at least one case, sorted by name. See below.
readingsarray of stringsoptionalEvery reading the corpus considered when it recorded meanings, sorted: yaml-1.2-core, yaml-1.1.
featuresarray of stringsoptionalEvery feature name used by at least one case, sorted.

Tag spec

Each entry of vocabulary describes one tag, so that a consumer can score a case from the file alone.

fieldtypepresentcontent
tagstringalwaysThe tag name, as it appears in a case’s tags.
stagestringalwaysThe earliest stage at which the question can arise: parse, compose or construct.
settledstringoptionalaccept or reject when the specification decides the question. Absent when each implementation chooses.
becausestringoptionalThe rule from the specification, and where it is stated.

Case

A refused mutant and the valid document it came from:

{"name":"generated/0000","src":"IiI=","wellFormed":true,"origin":{"document":0,"signature":"c7ae50c0…"}}
{"name":"generated/0000/mutant/01","src":"IiIi","wellFormed":false,"origin":{"document":0,"mutation":"duplicate a byte","signature":"c7ae50c0…"}}

An encoding shape, which carries a tag:

{"name":"shape/encoding/a utf-8 mark opening-a-document","src":"77u/eyJhIjoxfQ==","wellFormed":true,"tags":["encoding/bom"],"verdictAt":"construct","origin":{"document":0,"mutation":"enumerated"}}
fieldtypepresentcontent
namestringalwaysA name for the case, unique within the file.
srcbase64 stringalwaysThe test document, as raw bytes.
wellFormedbooleanalwaysThe grammar’s verdict, after removing the encoding properties a parser may normalize without loss. For JSON, a leading byte order mark is removed.
opaquebooleanoptional, default falsetrue when the bytes are not valid UTF-8 even after normalization. The oracle could not read them, so wellFormed tells nothing about a parser that decodes them some other way.
tagsarray of stringsoptionalThe implementation-defined properties of the document. Each one is listed in the header’s vocabulary.
featuresarray of stringsoptionalThe constructs the document contains, such as a flow collection or a CRLF line break. They never change the expected outcome.
verdictAtstringoptional, default parseThe last stage at which an acceptance by the grammar is evidence: parse, compose or construct. A refusal is evidence at every stage.
meaningmeaningoptionalWhat the document denotes under the specification’s default reading.
meaningsarray of meaningsoptionalWhat the document denotes under every reading that has an answer. Present only when the readings disagree; it repeats the default reading.
originoriginalwaysWhere the case came from. See below.

Origin

fieldtypepresentcontent
documentintegeralwaysThe index of the generated document the case comes from.
mutationstringoptionalHow the document was changed: a mutation name such as delete a byte, or enumerated for an encoding shape. Absent for a document generated whole.
signaturestringoptionalThe hex SHA-256 of the coverage fingerprint the builder used to select the case.

Meaning

fieldtypepresentcontent
understringalwaysThe reading: rfc8259, yaml-1.2-core, yaml-1.1.
jsonany JSON valueoptionalThe value, as JSON. null is a value; an absent field means there is none. Absent when cyclic is true.
cyclicbooleanoptional, default falsetrue when the value is a graph with a cycle, which has no JSON form.

Checks before scoring

Run these checks before you use a corpus file:

  1. The format. Reject a file whose format you do not support. Read format on its own first: a newer format may change the shape of other fields.
  2. The length. Count the case lines and compare the count with cases. A shorter file is truncated.
  3. The vocabulary. Every tag in vocabulary must be one your parser has a position on, or one the specification settles. A reader that ignores an unknown tag scores the case as if the tag were absent.
  4. The grammar, if you also run the oracle: compare digest with the digest of your grammar. A different digest means the verdicts came from another version of the grammar file.

The Go reader runs the first two checks. Call Header.Unknown for the third.

Compatibility

format changes only when a reader of the previous version would misunderstand a newer file.

Adding an optional field does not change format. A reader must ignore the fields it does not know. features, meanings and readings were all added this way: a reader that skips them still derives the same expected outcomes, and still finds the default reading in meaning.

Format 4 changed meaning.json from a base64 string to a JSON value. A format-3 reader cannot decode it.

Compare meanings as JSON values, not as text: the writer removes insignificant whitespace, and a reader that decodes numbers into 64-bit floats rounds the ones it cannot hold.

Do not rely on case names, or on the seed reproducing the corpus, to stay stable between releases.

Go

The suite package reads and writes this format:

  • suite.NewReader reads the header and returns a Reader. Reader.Next returns one case at a time and fails on a truncated file.
  • suite.ReadAll reads a whole file into memory. suite.FromBytes does the same for a file held in a byte slice, such as an embedded corpus.
  • suite.Content removes the gzip container and returns the JSON Lines.
  • suite.NewWriter and Writer.Add write a file. Writer.Close fails if the number of cases written differs from cases.
  • Header.Spec returns the tag spec for one tag. Header.MeaningFor returns the meaning of a case under one reading.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Tags

Generated

This page is written by go run hack/doc-site/gentags.go from each grammar’s Vocabulary(). Edit the doc comment on the tag’s constant, not this page.

A tag names an implementation-defined property a document exhibits. Every case in a corpus lists its tags, and the file’s header repeats each tag with its stage and, where the specification settles it, the outcome.

The stage is the earliest point at which the question can be asked: parse, compose or construct. A consumer that answers it later answers the same question. “Settled” means the specification fixes the outcome, so no stance can change it; “open” means each parser takes its own position.

Encoding

Declared in package stance and placed by the JSON grammar. A question about what the bytes denote, settled before parsing starts.

TagStageSpecificationWhat it marks
encoding/bomparseopenA document opening with a UTF-8 byte order mark. It declares no change of encoding, which is what makes ignoring it a defensible position and skipping the others not.
encoding/not-utf8parseopenBytes that are not well-formed UTF-8 at all: lone continuation bytes, overlong sequences, truncated sequences, surrogates encoded directly, and code points beyond U+10FFFF.
encoding/utf16parseopenA document that announces or looks like UTF-16.
encoding/utf32parseopenA document that announces or looks like UTF-32.

JSON

Placed by jsoncorpus.Vocabulary. RFC 8259 settles none of them: each one is a position a parser takes.

TagStageSpecificationWhat it marks
number/out-of-rangeconstructopenA number the grammar admits and float64 cannot carry: it overflows, underflows to zero, or is an integer too large to survive as one. RFC 8259 section 6 lets an implementation limit range and precision, so a parser that converts is exposed where a parser that keeps the text is not.
object/duplicate-namecomposeopenAn object holding two members of one name. RFC 8259 section 4 says names SHOULD be unique and calls the behavior of software receiving such an object unpredictable: it may keep the last, keep the first, or refuse.
string/lone-surrogateparseopenA \uXXXX escape naming a surrogate that is not part of a well-formed pair. RFC 8259 section 8.2 calls the behavior unpredictable. The escape itself is grammatical – four hex digits – so this is a question about the value, never about the syntax.
structure/deep-nestingparseopenA document nested more than 128 levels deep. No specification sets a limit and every parser has one, whether it says so or not. The generator stays well below that depth on purpose, so that no case tests the budget a parser keeps against hostile input.

YAML

Placed by yamlbuild.Vocabulary. A tag the specification settles carries the clause and the outcome it fixes, from yamlbuild.AllRules.

Anchors and aliases

TagStageSpecificationWhat it marks
anchor/alias-across-documentscomposeReject, section 3.2.2.2: anchor names are local to a document, so an earlier document’s anchor is out of scopeAn alias naming an anchor from an earlier document in the same stream.
anchor/alias-as-keycomposeAccept, section 7.1: an alias is a node, and a node may be a mapping keyAn alias used as a mapping key. Legal wherever a node is legal, which is a question about composing and not about the model underneath.
anchor/alias-forwardcomposeReject, section 7.1: the anchor must precede the alias, so a forward reference names nothingAn alias naming an anchor that occurs later.
anchor/alias-recursiveparseAccept, section 3.2.1: an anchor identifies its node from where the node begins, so an alias within it resolvesAn alias inside the node its own anchor names.
anchor/alias-undefinedcomposeReject, section 7.1: an alias refers to the most recent preceding node having the given anchor, and there is noneAn alias naming an anchor that never occurs.
anchor/cyclic-meaningconstructopenA document whose representation graph contains a cycle, which is a different question from whether it parses.
anchor/on-empty-nodecomposeAccept, section 7.1: the empty node is a node, and may be anchoredAn anchor on a node with no content.
anchor/redefinedcomposeAccept, section 3.2.2.2: an anchor name may be reused, and the alias takes the most recentThe same anchor name given to two nodes. Legal, and the later one wins.
anchor/unusedcomposeAccept, section 7.1: nothing requires an anchor to be referred toAn anchor nothing refers to. Legal, and worth having because it is the shape a parser is most likely to have simply dropped.

Directives

TagStageSpecificationWhat it marks
directive/handle-out-of-scopecomposeReject, section 6.8.2.2: TAG directives apply to the document that follows them, so a later document has no such handleA handle declared for one document and used in a later one.
directive/multiplecomposeAccept, section 6.8: nothing limits a document to one directive, and a %YAML with a %TAG is the ordinary preludeA document with more than one directive, which is ordinary: a %YAML and a %TAG together are the commonest prelude there is.
directive/reservedcomposeAccept, section 6.8: a directive a processor does not recognize is ignored with a warning, not refusedA directive that is neither %YAML nor %TAG, which the spec says to ignore with a warning rather than refuse.
directive/tag-handle-repeatedcomposeReject, section 6.8.2.2: it is an error to specify more than one TAG directive for the same handle in the same documentThe same %TAG handle declared twice for one document.
directive/yaml-major-versioncomposeReject, section 6.8.1: a processor must reject a directive whose major version differs from its ownA %YAML whose major version is not 1, which a 1.x processor must refuse rather than guess at.
directive/yaml-minor-versioncomposeopenA %YAML whose minor version is beyond what the processor knows – 1.9 today.
directive/yaml-repeatedcomposeReject, section 6.8.1: it is an error to specify more than one YAML directive for the same documentTwo %YAML directives for one document.
directive/yaml-versionparseopenA %YAML directive stating the version.

escape

TagStageSpecificationWhat it marks
escape/past-unicodecomposeReject, section 5.7: \U escapes a 32-bit Unicode character, and no character lies past U+10FFFFA double-quoted scalar holding a \U escape past U+10FFFF.

indentation

TagStageSpecificationWhat it marks
indentation/tab-opens-contentparseopenA root block scalar whose first content line opens with a tab at column 0.

JSON representation

TagStageSpecificationWhat it marks
json/not-representableconstructopenA document whose meaning has no JSON form: a non-finite float, or an entry keyed on a collection.

Mapping keys

TagStageSpecificationWhat it marks
key/distinct-after-resolutioncomposeAccept, section 3.2.1.1: keys resolving to different nodes are different keys, however alike they lookTwo keys that look nearly alike and are not equal, because resolution gives them different types.
key/duplicateparseReject, section 3.2.1.1: it is an error for two equal keys to appear in the same mapping nodeTwo keys with the same spelling.
key/duplicate-after-resolutioncomposeReject, section 3.2.1.1: keys are equal when they resolve to the same node, however they are writtenTwo keys that are equal only once they are resolved: quoting removed, tags applied, aliases followed.
key/integral-floatconstructopenA mapping key that resolves to a float whose value is a whole number: 1.0, 1e3, -0.0.
key/not-a-scalarconstructopenA mapping key that resolves to a collection.
key/not-a-stringconstructopenA mapping key that resolves to something other than a string: a number, a boolean, a null.

Merge keys

TagStageSpecificationWhat it marks
merge/into-non-mappingconstructopen<< given something that is not a mapping.
merge/keyconstructopenA << key whose value is an alias to a mapping – the construct working as intended.
merge/key-aloneconstructopenA << written as a flow entry’s key with no :.
merge/quotedconstructopenA quoted <<, which suppresses the merge in every reading because quoting resolves it to a string.
merge/sequenceconstructopen<< given a sequence of mappings, which 1.1 merges in order with the earlier winning.
merge/written-in-placeconstructopen<< given a mapping written where it stands, rather than an alias to one written elsewhere.

Representation in a model

TagStageSpecificationWhat it marks
representation/binaryconstructopenA !!binary, whose value a model holds as raw bytes or as the base64 text.
representation/float-inexactconstructopenA float written with more digits than the model’s float type keeps, so a reader into one rounds and the document’s digits are not what it holds.
representation/float-non-finiteconstructopen.inf, -.inf or .nan: a float a model may hold, refuse, or never resolve to a float in the first place.
representation/float-out-of-rangeconstructopenA float whose magnitude is past what the model’s float type holds, in either direction: it overflows to an infinity or underflows to zero.
representation/integer-wideconstructopenAn integer past what a machine word holds, which a model may hold whole, round to a float, or refuse.
representation/ordered-mapconstructopenAn !!omap, whose entries a model holds as ordered pairs or as a plain mapping.
representation/timestampconstructopenA !!timestamp, whose value a model holds as a moment, as a zoned text, or as the text the document wrote.

Schema resolution

TagStageSpecificationWhat it marks
schema/bool-legacyconstructopenA scalar YAML 1.1 read as a boolean and 1.2 does not: yes, no, on, off, y, n and their capitalizations.
schema/float-exponent-onlyconstructopen1e3: digits and an exponent with no decimal point. A float under 1.2’s core schema and under JSON, and a string under 1.1, whose float required a point.
schema/float-specialconstructopen.inf and .nan. Floats under core, strings under failsafe and under JSON, which has no way to write either.
schema/int-binaryconstructopen0b1010. A YAML 1.1 integer, and nothing in 1.2.
schema/int-non-decimalconstructopen0x1A and 0o17: core integers, and strings under the JSON schema, which writes neither.
schema/int-octal-legacyconstructopenA leading zero. YAML 1.1 read 0777 as octal 511; 1.2 spells octal 0o777 and leaves the leading-zero form as a decimal or a string. It is the disagreement most likely to be load-bearing, because file modes are written this way and both readings are plausible numbers.
schema/int-sexagesimalconstructopen1:30. A YAML 1.1 integer meaning 90, and a string in 1.2 – which is why 12:34:56 is a time in some documents and a string in others.
schema/int-underscoresconstructopen1_000. A YAML 1.1 integer, and nothing in 1.2.
schema/timestamp-legacyconstructopen2001-12-14. A timestamp in YAML 1.1, which had the type, and a string in 1.2, which does not.

Separation

TagStageSpecificationWhat it marks
separation/tabparseopenA document separating with a tab where a space would do.

Tags on nodes

TagStageSpecificationWhat it marks
tag/binary-not-base64constructopen!!binary not base64!.
tag/bool-not-a-booleanconstructopen!!bool 7.
tag/float-not-a-numberconstructopen!!float xyz.
tag/int-not-an-integerconstructopen!!int abc.
tag/kind-mismatchconstructopenA tag over a node of the wrong kind: a collection tag on a scalar or on the other collection, or a scalar tag on a collection.
tag/localconstructopenA ! shorthand, whose meaning is the application’s.
tag/named-handleparseopenA shorthand using a handle a %TAG directive declared.
tag/non-specificcomposeAccept, section 6.9.1: a non-specific tag is legal, and asks that resolution be suppressedA bare !, which suppresses resolution rather than naming a type.
tag/null-not-nullconstructopen!!null 5.
tag/omap-not-a-sequence-of-pairsconstructopen!!omap over anything but a sequence of one-entry mappings: an element that is not a mapping, an element holding two entries, the tag on a mapping, or one key written twice.
tag/percent-escapeparseopenA tag URI carrying a percent escape, which is the only route to a hex digit outside a quoted scalar.
tag/secondarycomposeAccept, section 6.8.2.2: the secondary handle is declared by default as tag:yaml.org,2002:A !! shorthand, which resolves through the secondary handle to tag:yaml.org,2002: unless a %TAG says otherwise.
tag/timestamp-not-a-dateconstructopen!!timestamp not-a-date.
tag/undeclared-handleparseReject, section 6.8.2.2: a tag shorthand must use a handle a %TAG directive declared, and this one does notA shorthand whose handle no %TAG declares.
tag/verbatimcomposeAccept, section 6.8.2.1: a verbatim tag is used as presented and resolves through nothingA tag written out in full between angle brackets, which resolves through nothing at all.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Consensus report

The consensus report compares five YAML parsers on every case of the compact YAML corpus. For each parser it scores the verdict (accept or reject), the loaded value and the round trip against the corpus, and lists the cases on which the parsers disagree, by tag and by feature.

Open the consensus report

Corpus: tier compact, 28,279 cases, grammar YAML 1.2.

ParserImplementationVersion
perlrefYAML 1.2 reference parser (Perl), yaml/yaml-reference-parsermain d58347b997eea4d7e5ba33b36871535dad6db081
libfyamllibfyaml (C): fy-tool for events, the Python binding for valuesbinding 1.0.0rc2, 1.0.0-rc2
yamlstarYAMLStar (Clojure), its own reference parseryaml v0.1.28
yaml.v3go.yaml.in/yaml/v3 (Go)go.yaml.in/yaml/v3 v3.0.6
go-yamlgithub.com/go-openapi/go-yaml (Go)go-openapi/go-yaml: v0.0.0-20261126182158-1aed24577d00
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Project

This section holds material specific to this repository:

  • README — repo overview
  • License — Apache-2.0, and the third-party notices
  • Maintainers — package layout and releasing

Documentation that applies to every go-openapi repository lives in the shared doc-site:

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Subsections of Project

README

Outline

This page will carry a copy of the repository README, the way every go-openapi doc site does. The README’s usage sections overlap Getting started: decide which one holds the example before copying.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

LICENSE

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright [yyyy] [name of copyright owner]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Third-party notices

See NOTICE: the YAML Test Suite and JSONTestSuite fixtures (MIT), and yaml-spec-1.2.json, which states no license.

Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

NOTICE

Copyright 2025-2026 go-swagger maintainers

// SPDX-FileCopyrightText: Copyright 2025-2026 go-swagger maintainers
// SPDX-License-Identifier: Apache-2.0

This software library, github.com/go-openapi/conformance-suites, includes software developed
by the go-swagger and go-openapi maintainers ("go-swagger maintainers").

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this software except in compliance with the License.

You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0.

This software ships with copies of other software which license terms are recalled below.

Third-party notices for github.com/go-openapi/conformance-suites
============================================================

github.com/yaml/yaml-grammar -- yaml/testdata/yaml-spec-1.2.json
------------------------------------------------------------

yaml/testdata/yaml-spec-1.2.json is copied unmodified from
https://github.com/yaml/yaml-grammar/blob/68cba4e5c77f13b316da71b129da9b986ea80a55/yaml-spec-1.2.json
(git blob 69cc3ee97ed22f97bb16b0dd76f8eff57742391c, identical on master as of 2026-11-22).
The yaml package embeds it and compiles the YAML 1.2 recognizer from it.

That repository states no license, and neither does https://github.com/yaml/yaml-spec.
We have not been granted a license for this file. It is not covered by this project's
Apache-2.0 license.

github.com/yaml/yaml-test-suite -- internal/yamltestsuite/testdata/
------------------------------------------------------------

The conformance fixtures under internal/yamltestsuite/testdata are used unmodified from
https://github.com/yaml/yaml-test-suite, under the MIT License. A copy of that
license is provided verbatim below and vendored alongside the fixtures at
internal/yamltestsuite/testdata/LICENSE.

(internal/yamltestsuite/yaml.go is not part of the suite: it is this project's
loader for the fixtures, and is covered by the root LICENSE.)

MIT License

Copyright (c) 2016-2020 Ingy döt Net

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

github.com/nst/JSONTestSuite -- internal/jsontestsuite/testdata/
------------------------------------------------------------

The conformance fixtures under internal/jsontestsuite/testdata/test_parsing are used unmodified from
https://github.com/nst/JSONTestSuite at revision 1ef36fa, under the MIT License. A copy of that
license is provided verbatim below and vendored alongside the fixtures at
internal/jsontestsuite/testdata/LICENSE.

(internal/jsontestsuite/json.go is not part of the suite: it is this project's
loader for the fixtures, and is covered by the root LICENSE.)

MIT License

Copyright (c) 2016 Nicolas Seriot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Last edited by: Frederic BIDON Nov 28, 2026
Copyright 2025-2026 go-openapi maintainers. This documentation is under an Apache 2.0 license.

Maintainers

Outline

This page is an outline. The structure is up for review; the prose is not written.

What the page must answer

  • Where does a new grammar, generator or helper go?
  • Which packages are public, and why?
  • When does a second module appear?
  • How is a corpus regenerated, and how is a release cut?

Sections

  • One directory per grammar (json, yaml); suite and stance beside them; the engine in internal/grammar
  • Public: suite and stance (a consumer reads a file and declares a table); the oracle’s result types
  • Each grammar package re-exports the engine types it returns: type Result = grammar.Result
  • Package names carry the grammar: jsoncorpus, yamlcorpus, yamlgen
  • No parser imported in the root module, tests included; consensus is a module of its own
  • One module until a dependency or an embed forces a split (yaml/corpus)
  • Regenerating the compact corpus, and the regenerate-and-diff test
  • Updating metrics.yaml
  • Releasing: bump-release.yml or a signed semver tag; corpus assets once released

The consensus report

The consensus image (yaml/consensus/docker/Dockerfile) pins every parser, go-openapi/go-yaml included. Bump the go-yaml pin by hand, together with the stance files it needs. Each release runs the image on the compact corpus and attaches the results file, consensus-results.jsonl.gz, to the release. The doc site renders the consensus report from the results file of the latest release.

To produce a report yourself, build the image and run it on a corpus file, as the Dockerfile’s header describes. Then render it into this site, under /consensus/, or into any directory:

hack/doc-site/consensus-report.sh results.jsonl.gz
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" conformance-consensus \
  report -o /work/report /work/results.jsonl

The script also writes the results header to hack/doc-site/hugo/data/consensus.json, which the reference page reads. Both outputs are gitignored.