Skip to content

feat: add file path to origin location tracking#1128

Open
reuvenharrison wants to merge 11 commits intogetkin:masterfrom
oasdiff:feat/origin-file-tracking
Open

feat: add file path to origin location tracking#1128
reuvenharrison wants to merge 11 commits intogetkin:masterfrom
oasdiff:feat/origin-file-tracking

Conversation

@reuvenharrison
Copy link
Contributor

Summary

  • Adds File field to the Location struct in origin tracking, propagating file paths from the YAML parser through to the OpenAPI loader
  • When IncludeOrigin is enabled, each Location (key positions, field positions) now carries the source file path in addition to line/column
  • Enables downstream tools (like oasdiff) to report precise file:line:column for every detected change

Changes

  • openapi3/origin.go: Add File string field to Location struct
  • openapi3/loader.go: Propagate file paths from YAML decoder nodes into origin locations
  • openapi3/origin_test.go: Update all 26 location literals and fix external ref test expectation

Test plan

  • All 12 origin tests pass including TestOrigin_WithExternalRef
  • Full test suite passes (go test ./...)
  • Backward compatible - File is omitempty, no behavior change when IncludeOrigin is false

🤖 Generated with Claude Code

Pass file path through the origin chain (yaml3 → yaml → kin-openapi)
so that each Location includes which file it came from. This enables
source location tracking for external $ref resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@reuvenharrison reuvenharrison force-pushed the feat/origin-file-tracking branch from 382f0b0 to ea052d6 Compare February 18, 2026 12:32
reuvenharrison and others added 5 commits February 18, 2026 23:06
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Regenerate .github/docs/*.txt to match go doc output
- Document Location and Origin struct changes in README changelog
- Fix docs.sh heading grep to match actual README heading

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
if location != nil {
file = location.Path
}
if yamlErr = yaml.UnmarshalWithOrigin(data, v, includeOrigin, file); yamlErr == nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This line needs to be fixed.
A lot of my works services are screaming "vendor/github.com/getkin/kin-openapi/openapi3/marsh.go:28:49: not enough arguments in call to yaml.UnmarshalWithOrigin"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please provide a spec that generates this error?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, just chipping-in, here's response of the maintainers on this issue (tldr; they're reverting it). I've also closed #1130 based on this.

reuvenharrison and others added 5 commits February 19, 2026 16:07
Updates dependencies to use the sequence origin tracking versions.
Fixes origin tests to expect Location.Name populated by yaml3.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The docs.sh script iterates git-tracked directories and runs
go doc on each. The .claude/skills/pre-commit directory has no
Go source files, causing the CI to fail.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI docs.sh fails on non-Go directories.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

3 participants