Skip to content

chore: upgrade to libopenapi v0.41.1 and github.com/pb33f/go-yaml - #324

Merged
daveshanley merged 1 commit into
mainfrom
libopenapi-v0.41
Sep 28, 2026
Merged

daveshanley merged 1 commit into
mainfrom
libopenapi-v0.41

Conversation

@daveshanley

@daveshanley daveshanley commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Brings the validator up to libopenapi v0.41.1. That includes the move to github.com/pb33f/go-yaml and one fix for a libopenapi behavior change that broke two tests.

Dependencies

CI

  • The build job now reads the Go version from go.mod. It was pinned to 1.25. Checkout now runs before setup-go so the file exists when setup-go reads it.
  • golangci-lint v2.8 → v2.12. v2.12 is built with Go 1.26 and can lint a Go 1.26 module. Locally, golangci-lint run ./... reports 0 issues.

Fix: referenced schemas and their root document

These two tests pass against libopenapi v0.38.6 and fail from v0.39 on:

  • TestSingleSchemaCompilePreferred_ResolvedExternalReferenceUsesSingleSchemaCompiler
  • TestCompileSchemaForValidation_NestedResourceRenderFailure

What changed in libopenapi. v0.39 started attributing schemas to the file their content came from. For a component-level $ref, Schema().GetIndex() now names the target file (models.yaml). The schema's root node deliberately stays the authored $ref node in the referring file (openapi.yaml).

Why the validator failed. buildSchemaDocumentResources searched for that node in the target file's document. It wasn't there, so the function returned schema node was not found in its root document.

The fix. schemaRootLocation looks for the node in the schema's index first. If it isn't there, it tries the parent proxy's index, which libopenapi documents as the file the $ref was written in. The function then builds the resource set from whichever document holds the node. That restores the v0.38.6 resource layout: an entry pointer into openapi.yaml, plus the reachable models.yaml resource.

Tests

  • go build, go vet, golangci-lint and go test -race ./... all pass.
  • TestSchemaRootLocation covers the node being in the schema's own document, and being in no candidate document with a parent proxy that has no index.
  • New code is at 100%. Overall coverage matches main (98.6%), and the previously uncovered blocks are unchanged.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.27%. Comparing base (f309f59) to head (4a37d8f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #324   +/-   ##
=======================================
  Coverage   98.27%   98.27%           
=======================================
  Files          75       75           
  Lines        9192     9203   +11     
=======================================
+ Hits         9033     9044   +11     
  Misses        132      132           
  Partials       27       27           
Flag Coverage Δ
unittests 98.27% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Move to libopenapi v0.41.1, and with it from go.yaml.in/yaml/v4 to
github.com/pb33f/go-yaml v0.1.0, pb33f's fork. libopenapi's models carry
the fork's yaml.Node, so the validator has to use the same module. The
package is still named yaml, so the change is the import path. jsonpath
moves to v0.8.4 and testify to v0.1.1, which use the same module.

libopenapi requires Go 1.26, so go.mod does too. CI's build job now
reads the Go version from go.mod (checking out first so the file
exists), and golangci-lint moves to v2.12, which is built with Go 1.26.

Since libopenapi v0.39, a schema built from a component-level $ref
reports the index of the file its content came from, while its root
node stays the authored $ref node in the referring file.
buildSchemaDocumentResources looked for that node in the wrong document
and failed with "schema node was not found in its root document". It
now finds the node in the schema's index or, failing that, in its
parent proxy's index, which libopenapi documents as the file the $ref
was written in. This fixes
TestSingleSchemaCompilePreferred_ResolvedExternalReferenceUsesSingleSchemaCompiler
and TestCompileSchemaForValidation_NestedResourceRenderFailure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@daveshanley daveshanley changed the title chore: upgrade to libopenapi v0.41.0 and github.com/pb33f/go-yaml chore: upgrade to libopenapi v0.41.1 and github.com/pb33f/go-yaml Sep 28, 2026
@daveshanley
daveshanley merged commit 949b538 into main Sep 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant