Skip to content

refactor: replace Loader interface with *openapi3.Loader#800

Merged
reuvenharrison merged 2 commits intomainfrom
refactor/remove-loader-interface
Mar 9, 2026
Merged

refactor: replace Loader interface with *openapi3.Loader#800
reuvenharrison merged 2 commits intomainfrom
refactor/remove-loader-interface

Conversation

@reuvenharrison
Copy link
Collaborator

Summary

  • Removes the Loader interface from the load package
  • Replaces all usages with *openapi3.Loader (the only real implementation that ever existed)
  • Deletes mock_loader_test.go — MockLoader just delegated to openapi3.NewLoader()
  • Updates TestLoadInfo_URI to use a real httptest server instead of the mock's URL-to-file redirect

Why the interface wasn't pulling its weight

  • The return type *openapi3.T already pins every caller to kin-openapi — there was no real abstraction
  • Only one production implementation existed (*openapi3.Loader)
  • MockLoader provided no meaningful isolation — it called the real 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/... passes
  • TestLoadInfo_URI now uses a real httptest server
  • No regressions across the full test suite

🤖 Generated with Claude Code

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-commenter
Copy link

codecov-commenter commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.54%. Comparing base (4c8d48e) to head (e43172d).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
load/option.go 75.00% 1 Missing ⚠️
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              
Flag Coverage Δ
unittests 89.54% <90.90%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

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 reuvenharrison merged commit adcd2c5 into main Mar 9, 2026
14 checks passed
@reuvenharrison reuvenharrison deleted the refactor/remove-loader-interface branch March 9, 2026 10:37
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]>
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.

2 participants