Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
79ac3c4
openapi3: ignore the fields next to a Reference Object's $ref in ever…
fenollp Oct 19, 2026
0375a5d
openapi3: apply a 3.1 schema's $ref siblings alongside the referenced…
fenollp Oct 19, 2026
cb14646
openapi3: marshal the fields written next to a $ref
fenollp Oct 15, 2026
11caa38
openapi3: tell apart a $ref being resolved as different kinds of objects
fenollp Oct 19, 2026
c59eda0
openapi3: merge the fields next to a path item's $ref with the item i…
fenollp Oct 19, 2026
98fd8d4
openapi3: internalize, version and locate the keywords next to a sche…
fenollp Oct 20, 2026
52aade8
openapi3: test $ref siblings with the cases of #1271
abramchikd Oct 20, 2026
2420538
changelog: fixup rebased messes (#1372)
fenollp Oct 22, 2026
15948ef
Add fuzz targets (#1373)
fenollp Oct 22, 2026
454df67
openapi3: set the failing schema on JSON Schema 2020-12 validation er…
frodeaa Oct 23, 2026
7dd0f6c
openapi3filter: parse number values as decimal only (#1366)
LuisFigueroaG Oct 24, 2026
5c5819e
openapi3: marshal a ref holding neither $ref nor a value as null
fenollp Oct 25, 2026
c5fa940
openapi2conv: fix nil dereferences and input mutation in FromV3
fenollp Oct 25, 2026
5a3af78
fuzz: seed from all of testdata and the APIs-guru corpus, cover the Y…
fenollp Oct 25, 2026
8424c16
openapi3filter: decode query, path, header and cookie params with typ…
Yi-111-a Oct 22, 2026
44f4af5
openapi3filter: typeless const/enum decode with a slice of types, ext…
Oct 22, 2026
0d96dff
openapi3filter: simplify typeless const/enum type derivation, name su…
Oct 26, 2026
b8b4f18
openapi3filter: derive typeless const/enum candidate types in O(values)
Yi-111-a Oct 26, 2026
21622f0
openapi2conv: handle some nil derefs (#1384)
reuvenharrison Oct 26, 2026
4b868ce
ci: a minimize budget the minimizer can finish in (#1385)
reuvenharrison Oct 26, 2026
9ff7e37
openapi3: return a typed error for a disallowed external $ref (#1370)
reuvenharrison Oct 26, 2026
8d12901
openapi3: reject a multipleOf of zero or less in Schema.Validate (#1379)
LuisFigueroaG Oct 27, 2026
2e311b6
openapi3filter: treat a handler that writes no status as a 200 in Val…
LuisFigueroaG Oct 27, 2026
b959388
deps: update oasdiff/yaml to v0.1.3 (#1387)
reuvenharrison Oct 28, 2026
f074d9a
openapi3: validate the pattern of a schema without type in Schema.Val…
LuisFigueroaG Oct 29, 2026
f58588b
openapi3: set maxLength in Schema.WithMaxLengthDecodedBase64 (#1401)
LuisFigueroaG Oct 29, 2026
aaf4e27
openapi2conv: FromV3 no longer turns a binary header into a form fiel…
fenollp Oct 29, 2026
3fbcfc9
openapi3: internalize webhook references (#1408)
KashifManzer Oct 30, 2026
5aa7973
openapi2conv: keep required and format on a converted form field (#1405)
reuvenharrison Oct 30, 2026
7c95f0a
openapi2conv: escape a base path converted to a server of its own (#1…
reuvenharrison Oct 30, 2026
74727a2
internal: add nodeindex (decoding YAML natively 1/3) (#1382)
reuvenharrison Oct 30, 2026
545c898
openapi3: UnmarshalYAML for the types (decoding YAML natively 2/3) (#…
reuvenharrison Oct 30, 2026
1a0fab2
openapi3: keep component content when internalizing a ref to a file (…
akasakariko Oct 30, 2026
3d94c22
openapi3: skip nil map entries when internalizing refs
fenollp Oct 31, 2026
17aed50
openapi3: never name an internalized component ""
fenollp Oct 31, 2026
81a32c0
openapi3: leave unfollowed refs alone when internalizing
fenollp Oct 31, 2026
0d11ec9
openapi3: report a ref into a missing part of its own document
fenollp Oct 31, 2026
edb3ecd
openapi3: record no path for a ref that resolves to nothing
fenollp Oct 31, 2026
c26b4a2
openapi3: follow the $ref of a file a ref points to as a whole
fenollp Oct 31, 2026
80b6048
openapi2, openapi3: do not discard errors decoding extensions
fenollp Oct 31, 2026
2471495
openapi3: terminate Schema.IsEmpty on cyclic schemas
fenollp Oct 31, 2026
b484990
openapi2, openapi3: write missing required maps as null in YAML too
fenollp Oct 31, 2026
e3e3b24
openapi3filter: no panic decoding a form body without a schema
fenollp Oct 31, 2026
1cdf081
openapi3filter: decode YAML bodies with non-string keys to map[string…
fenollp Oct 31, 2026
6c870be
openapi2: emit YAML from the generic form in FuzzUnmarshalFromData
fenollp Oct 31, 2026
e57ca64
openapi3: validate discriminators and the schemas their mapping loads
fenollp Nov 1, 2026
84645cd
openapi3: add FuzzInternalizeRefs
fenollp Oct 31, 2026
767eb7d
openapi3: add FuzzInternalizeRefsKeepsMeaning
fenollp Oct 31, 2026
3d3b367
openapi3: add FuzzValidateOptions
fenollp Oct 31, 2026
fafe475
openapi3: add FuzzInternalizeRefsCustomResolver
fenollp Oct 31, 2026
48e3ec4
openapi3: write a nil dependentRequired list as null in YAML too
fenollp Oct 31, 2026
5a0cd1e
openapi3: add FuzzMarshalYAML
fenollp Oct 31, 2026
d43935b
openapi3filter: add FuzzValidateResponse
fenollp Oct 31, 2026
683e535
openapi3filter: add FuzzBodyDecoder
fenollp Oct 31, 2026
99d5439
routers: add FuzzRoutersAgree
fenollp Oct 31, 2026
d8955bb
openapi3: nit
fenollp Oct 31, 2026
76af206
ci: check out before setup-go so its cache works
fenollp Nov 1, 2026
2fe77d6
openapi3filter: test deepObject array index limits (#1412)
connabyss Nov 1, 2026
b91a681
openapi3: scope whole-file schema fragments to their document (#1413)
Aryangupta-05 Nov 1, 2026
368af76
openapi3: compare FuzzLoadFromData's validation errors by message (#1…
fenollp Nov 1, 2026
29427b0
openapi3: internalize refs under the 3.1 subschema keywords (#1418)
fenollp Nov 1, 2026
787f45f
openapi3: an extension next to a $ref reaches the schema it resolves …
reuvenharrison Nov 2, 2026
e21ab80
openapi3: DefaultRefNameResolver stops stripping extensions at the la…
Yi-111-a Nov 2, 2026
2fe145b
openapi3: isolate reference sibling constraints (#1406)
subotac Nov 4, 2026
de92908
openapi3: reject impossible days and offsets in the date and date-tim…
LuisFigueroaG Nov 4, 2026
4daab6c
openapi3: stop InternalizeRefs prefix trimming at the filesystem root…
Yi-111-a Nov 5, 2026
06b0438
openapi3: resolve refs under a header's content (#1424)
JayOfTheKeyboard Nov 5, 2026
13bce60
openapi3filter: reject an empty query value instead of filling in the…
fyousfi-ionos Nov 5, 2026
74fda39
openapi3: reuse root components when internalizing refs (#1425)
ZXLyyds100 Nov 5, 2026
352287a
openapi3filter: read OpenAPI 3.1 contentMediaType data without a regi…
nk-batman21 Nov 6, 2026
6f0e561
openapi3: validate the callbacks of an operation (#1429)
fenollp Nov 6, 2026
83df2b6
fuzzing: add ./fetch-fuzz-crashers.sh [--days N] (#1428)
fenollp Nov 6, 2026
ec0a820
openapi3: internalize the refs next to a $ref in OpenAPI 3.1 (#1430)
fenollp Nov 6, 2026
fe68b90
openapi3: internalize the examples of parameters and headers (#1431)
fenollp Nov 6, 2026
b523491
openapi2, openapi3: skip the json decode when data cannot be json, wr…
fenollp Nov 7, 2026
340e8d1
openapi3: switch the loader to the native decode
reuvenharrison Nov 7, 2026
9813bd9
openapi2: decode a swagger document without the yaml fork
reuvenharrison Nov 7, 2026
8e02f32
ci: run the origin concurrency test under -race
reuvenharrison Nov 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .github/docs/openapi2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ backwards-compatible with version 2, version 3 elements have been used.

See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

FUNCTIONS

func UnmarshalFromData(data []byte, doc *T) error
UnmarshalFromData loads a document from swagger 2.0 bytes in either JSON or
YAML. The v3 side has Loader for this; here the whole job is the decode.


TYPES

type Header struct {
Expand Down
189 changes: 179 additions & 10 deletions .github/docs/openapi3.txt

Large diffs are not rendered by default.

130 changes: 130 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: fuzz
on:
pull_request:
push:
branches:
- master
schedule:
# Nightly, so a long run has a chance to reach code a 90s PR run never does.
- cron: '17 3 * * *'
workflow_dispatch:
inputs:
fuzztime:
description: 'How long to fuzz each target (go test -fuzztime syntax)'
required: false
default: 30m

permissions:
contents: read

jobs:
fuzz:
name: ${{ matrix.target }}
runs-on: ubuntu-latest
# A budget of 15m plus corpus minimization has to fit, and a hung target
# must not hold a runner forever.
timeout-minutes: 45
env:
# Keep in sync with the go workflow, whose cache this restores.
APISGURU_COMMIT: f7207cf0a5c56081d275ebae4cf615249323385d
GO111MODULE: 'on'
CGO_ENABLED: '0'
strategy:
# Every target reports independently: one crasher must not hide the rest.
fail-fast: false
matrix:
include:
- {package: ./openapi3, target: FuzzLoadFromData}
- {package: ./openapi3, target: FuzzLoadWithOrigins}
- {package: ./openapi3, target: FuzzYAMLMatchesJSON}
- {package: ./openapi3, target: FuzzSchemaVisitJSON}
- {package: ./openapi3, target: FuzzInternalizeRefs}
- {package: ./openapi3, target: FuzzInternalizeRefsKeepsMeaning}
- {package: ./openapi3, target: FuzzValidateOptions}
- {package: ./openapi3, target: FuzzInternalizeRefsCustomResolver}
- {package: ./openapi3, target: FuzzMarshalYAML}
- {package: ./openapi2, target: FuzzUnmarshalFromData}
- {package: ./internal/nodeindex, target: FuzzNew}
- {package: ./openapi2conv, target: FuzzToV3}
- {package: ./openapi3filter, target: FuzzValidateRequest}
- {package: ./openapi3filter, target: FuzzValidateResponse}
- {package: ./openapi3filter, target: FuzzBodyDecoder}
- {package: ./routers, target: FuzzRoutersAgree}
steps:

# Checked out first: setup-go keys its module and build cache on go.sum,
# and without one it caches nothing.
- uses: actions/checkout@v6

- uses: actions/setup-go@v6
with:
go-version: stable

# The APIs-guru corpus seeds the fuzzers alongside testdata. The go
# workflow caches it, so fetch it only when that cache is missing.
- name: APIs-guru corpus cache
id: apisguru
uses: actions/cache/restore@v4
with:
path: |
openapi2/testdata/APIs-guru-openapi-directory-*
openapi3/testdata/APIs-guru-openapi-directory-*
key: suite-${{ env.APISGURU_COMMIT }}

- name: Fetch APIs-guru corpus
if: steps.apisguru.outputs.cache-hit != 'true'
run: |
dir=openapi3/testdata/APIs-guru-openapi-directory-${APISGURU_COMMIT:0:7}
mkdir -p "$dir"
curl -fsSL "https://github.com/APIs-guru/openapi-directory/tarball/$APISGURU_COMMIT" | tar -xz -C "$dir"

# The generated corpus lives under $GOCACHE/fuzz and is what makes fuzzing
# cumulative: without it every run restarts from the seed corpus. The key
# carries the run id so each run writes a fresh entry, and restore-keys
# falls back to the most recent one for this target.
- name: Fuzzing corpus cache
uses: actions/cache@v4
with:
path: ~/.cache/go-build/fuzz
key: fuzz-${{ matrix.target }}-${{ github.run_id }}
restore-keys: fuzz-${{ matrix.target }}-

- name: Pick a budget
id: budget
run: |
if [[ -n '${{ inputs.fuzztime }}' ]]; then
fuzztime='${{ inputs.fuzztime }}'
elif [[ '${{ github.event_name }}' = schedule ]]; then
fuzztime=15m
else
fuzztime=90s
fi
echo "fuzztime=$fuzztime" >>"$GITHUB_OUTPUT"

# -run='^$' skips the ordinary tests: the seed corpus is already replayed by
# `go test ./...` in the go workflow, so this job only spends time fuzzing.
#
# The minimize budget is small on purpose. A minimize that cannot finish
# inside it writes the candidate it had and the job fails with "fuzzing
# process hung or terminated unexpectedly while minimizing", whose
# candidate then passes on replay: a red build and nothing to act on. The
# budget only decides how small the saved input gets, so spending less of
# it costs a larger seed and buys a signal that means what it says.
- name: Fuzz ${{ matrix.target }}
run: |
go test \
-run='^$' \
-fuzz='^${{ matrix.target }}$' \
-fuzztime='${{ steps.budget.outputs.fuzztime }}' \
-fuzzminimizetime=10s \
${{ matrix.package }}

# A failing input is written next to the package it broke. Upload it so the
# crasher can be committed to the seed corpus, where it becomes a permanent
# regression test replayed by `go test ./...`.
- if: failure()
uses: actions/upload-artifact@v4
with:
name: crashers-${{ matrix.target }}
path: '**/testdata/fuzz/**'
if-no-files-found: ignore
24 changes: 14 additions & 10 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ jobs:
name: ${{ matrix.go }} on ${{ matrix.os }}
steps:

# Checked out first: setup-go keys its module and build cache on go.sum,
# and without one it caches nothing.
- uses: actions/checkout@v6

- uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}

- if: runner.os == 'Linux'
run: sudo apt install silversearcher-ag

- uses: actions/checkout@v6

- name: Test suite fixtures cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
openapi2/testdata/APIs-guru-openapi-directory-*
Expand Down Expand Up @@ -75,9 +77,8 @@ jobs:
# TODO: drop once 1.26 & 1.27 Go no longer experiences flaky memory corruptions
- if: runner.os == 'Windows'
run: |
for i in 1 2 3 4 5; do
for _ in $(seq 1 20); do
go test -count=10 -short ./... && exit 0
echo "::warning::attempt $i/5 failed"
done
exit 1
- run: go test -count=2 -short -covermode=atomic ./...
Expand All @@ -90,6 +91,9 @@ jobs:
- run: go test -v -count=10 -run TestIssue741 -race ./...
env:
CGO_ENABLED: '1'
- run: go test -v -count=10 -run TestConcurrentDecodeDoesNotLeakOrigins -race ./...
env:
CGO_ENABLED: '1'
- run: git --no-pager diff --exit-code

- if: runner.os == 'Linux'
Expand All @@ -100,7 +104,7 @@ jobs:
- if: runner.os == 'Linux'
name: Did you mean %q
run: |
! git grep -E "'[%].'"
! git grep -E "'[%].'" -- '*.go' '*.tmpl'

- if: runner.os == 'Linux'
name: Also add yaml tags
Expand All @@ -117,9 +121,9 @@ jobs:
! git grep -IErn '\s$'

- if: runner.os == 'Linux'
name: Ensure use of unmarshal
name: Ensure yaml stays inside the decode layer
run: |
[[ "$(git grep -F yaml. -- openapi3/ | grep -v _test.go | grep -v origin.go | wc -l)" = 2 ]]
[[ "$(git grep -F yaml. -- openapi3/ | grep -v _test.go | grep -vE 'openapi3/(origin|marsh|refs|loader|native_yaml.*|nativeyaml.*)[.](go|tmpl)' | wc -l)" -eq 0 ]]

- if: runner.os == 'Linux'
name: Use `loader := NewLoader(); loader.Load ...`
Expand Down Expand Up @@ -201,9 +205,9 @@ jobs:
- if: runner.os == 'Linux'
name: Ensure readableType() covers all possible values of resolved var
run: |
[[ "$(git grep -F 'var resolved ' -- openapi3/loader.go | awk '{print $4}' | sort | tr '\n' ' ')" = "$RESOLVEDS" ]]
[[ "$(git grep -F 'var resolved ' -- openapi3/loader.go | awk '{print $4}' | sort | uniq | tr '\n' ' ')" = "$RESOLVEDS" ]]
env:
RESOLVEDS: 'Callback CallbackRef ExampleRef HeaderRef LinkRef ParameterRef PathItem RequestBodyRef ResponseRef SchemaRef SecuritySchemeRef '
RESOLVEDS: 'CallbackRef ExampleRef HeaderRef LinkRef ParameterRef PathItem RequestBodyRef ResponseRef SchemaRef SecuritySchemeRef '

check-goimports:
runs-on: ubuntu-latest
Expand Down
41 changes: 27 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
.DEFAULT_GOAL := prepare
.DEFAULT_GOAL := all
.PHONY: help generate format test test-fast fuzz all

.PHONY: help generate format test prepare
# How long to spend on each fuzz target. Override: make fuzz FUZZTIME=10m
FUZZTIME ?= 60s

help:
@printf '%s\n' \
'Usage: make <target>' \
'' \
' generate Regenerate Go code, map helpers, and API documentation.' \
' format Apply the repository formatters and import cleanup.' \
' test Run the full Go package test suite.' \
' prepare Run generation, formatting, and tests in sequence.'
## all: Run generation, formatting, and tests in sequence
all: generate format test

## generate: Regenerate Go code, map helpers, and API documentation
generate:
go generate ./...
./maps.sh
./docs.sh

## format: Apply the repository formatters and import cleanup
format:
go fmt ./...

## test: Run the full Go package test suite
test:
go test ./...

prepare:
$(MAKE) generate
$(MAKE) format
$(MAKE) test
## test-fast: Run tests skipping the slow ones
test-fast:
go test -short ./...

## fuzz: Fuzz each target for FUZZTIME (default 60s)
fuzz:
go test -run='^$$' -fuzz='^FuzzLoadFromData$$' -fuzztime=$(FUZZTIME) ./openapi3
go test -run='^$$' -fuzz='^FuzzLoadWithOrigins$$' -fuzztime=$(FUZZTIME) ./openapi3
go test -run='^$$' -fuzz='^FuzzYAMLMatchesJSON$$' -fuzztime=$(FUZZTIME) ./openapi3
go test -run='^$$' -fuzz='^FuzzSchemaVisitJSON$$' -fuzztime=$(FUZZTIME) ./openapi3
go test -run='^$$' -fuzz='^FuzzUnmarshalFromData$$' -fuzztime=$(FUZZTIME) ./openapi2
go test -run='^$$' -fuzz='^FuzzNew$$' -fuzztime=$(FUZZTIME) ./internal/nodeindex
go test -run='^$$' -fuzz='^FuzzToV3$$' -fuzztime=$(FUZZTIME) ./openapi2conv
go test -run='^$$' -fuzz='^FuzzValidateRequest$$' -fuzztime=$(FUZZTIME) ./openapi3filter

## help: list targets
help:
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / make /'
Loading