fix(swagger): match go-openapi/loads' DocLoader signature at v0.25+ - #147
Merged
Conversation
Fixes #146. go-openapi/loads v0.25.0 added a variadic loading.Option parameter to the DocLoader type. embedFsLoader in RenderDoc() had the pre-v0.25 signature, so it stopped satisfying loads.DocLoader the moment anything in the dependency graph pulls loads past v0.22.x - direct or transitive. grandturks hit this transitively: a routine dependabot bump of go-openapi/validate pulls loads up to v0.25.1 and fails to build restcol as a dependency, with no way to work around it from the consumer's side. Bumps go-openapi/validate to the version that surfaced this (v0.26.4, which itself requires loads v0.25.1) so the fix is exercised by this repo's own build, not left to whoever bumps it next downstream. The options parameter is unused - the embedded FS loader needs none of what loads.Spec's own callers can pass through it (a custom HTTP client, timeouts) - so it's accepted and discarded. Verified the error reproduces on v0.22.0 and disappears with the fix; RenderDoc's existing test (TestCollectionDoc) still passes and produces the same document, so this is a signature adaptation, not a behavior change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #146.
What broke, and why it's not obvious from this repo alone
go-openapi/loadsv0.25.0 added a variadicloading.Optionparameter to the exportedDocLoadertype.RenderDoc()'sembedFsLoaderclosure kept the pre-v0.25 signature, so it stops satisfyingloads.DocLoaderthe moment anything in a build's dependency graph pullsloadspast v0.22.x — direct or transitive. This repo still pinsloadsat v0.22.0, so it builds clean today; the break only shows up in a consumer's build once their own dependency graph (this repo included as a dependency) resolves a newerloads. grandturks hit it through a routinego-openapi/validatedependabot bump, with no way to work around it from their side — Go doesn't let a downstream module patch a dependency's function signature.What changed
pkg/swagger/collections/apidoc.go:embedFsLoadernow accepts the variadicloading.Optionparam (unused — the embedded FS loader needs none of whatloads.Spec's callers can pass through it, e.g. a custom HTTP client or timeouts)go.mod/go.sum: bumpedgo-openapi/validateto v0.26.4 (pullingloadsto v0.25.1) so the fix is actually exercised by this repo's own build, rather than left latent for whoever bumps it downstream nextTest evidence
go-openapi/validate/loadslocally and confirmed the exact compile error from grandturks's dependabot PRgo build ./...,go vet ./...cleango test ./... -short— all green, includingTestCollectionDoc(pkg/swagger/collections), which exercisesRenderDoc()directly and produces the identical rendered document before and after — this is a signature adaptation, not a behavior changevendor/is gitignored and regenerated in CI (go mod tidy && go mod vendor), so nothing to commit there🤖 Generated with Claude Code