refactor: replace Loader interface with *openapi3.Loader#800
Merged
reuvenharrison merged 2 commits intomainfrom Mar 9, 2026
Merged
refactor: replace Loader interface with *openapi3.Loader#800reuvenharrison merged 2 commits intomainfrom
reuvenharrison merged 2 commits intomainfrom
Conversation
The Loader interface provided no real abstraction: the return type *openapi3.T already pins all callers to kin-openapi, there was only one production implementation, and MockLoader simply delegated to openapi3.NewLoader(). Using the concrete *openapi3.Loader type directly: - removes the interface and mock boilerplate - unlocks LoadFromDataWithPath for future use (e.g. loading from git revisions without a temp file) - makes TestLoadInfo_URI use a real httptest server instead of a mock redirect Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #800 +/- ##
==========================================
- Coverage 89.55% 89.54% -0.01%
==========================================
Files 239 239
Lines 12154 12154
==========================================
- Hits 10884 10883 -1
- Misses 840 841 +1
Partials 430 430
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The MockLoader previously redirected http://localhost/null to a local file path, giving a platform-specific 'file not found' error. With the real loader the error is an HTTP response, so just assert any error occurs. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
reuvenharrison
added a commit
that referenced
this pull request
Mar 9, 2026
…g temp file Now that the Loader interface is gone (PR #800), use *openapi3.Loader directly and call LoadFromDataWithPath so relative $refs resolve against the spec path without needing a temporary file on disk. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.
Summary
Loaderinterface from theloadpackage*openapi3.Loader(the only real implementation that ever existed)mock_loader_test.go— MockLoader just delegated toopenapi3.NewLoader()TestLoadInfo_URIto use a realhttptestserver instead of the mock's URL-to-file redirectWhy the interface wasn't pulling its weight
*openapi3.Talready pins every caller to kin-openapi — there was no real abstraction*openapi3.Loader)What this unlocks
The concrete type has
LoadFromDataWithPath(data []byte, location *url.URL)which the interface didn't expose. This will be used in the follow-up PR (#799) to load git revision specs without needing a temp file.Test plan
go test ./load/... ./internal/...passesTestLoadInfo_URInow uses a real httptest server🤖 Generated with Claude Code