Skip to content

openapi3: strip __origin__ from slices in example values#1138

Merged
fenollp merged 2 commits intogetkin:masterfrom
oasdiff:fix/strip-origin-from-slices
Mar 31, 2026
Merged

openapi3: strip __origin__ from slices in example values#1138
fenollp merged 2 commits intogetkin:masterfrom
oasdiff:fix/strip-origin-from-slices

Conversation

@reuvenharrison
Copy link
Copy Markdown
Contributor

Summary

  • stripOriginFromAny only recursed into map[string]any but not []any slices
  • This caused __origin__ keys inside array elements to survive stripping
  • Affects example values containing lists of objects (e.g. request/response examples with arrays)
  • This causes oasdiff diff (and any other tool using this library) to report false positive diffs when comparing identical specs loaded from different file paths

Fix

Extend stripOriginFromAny to use a switch that handles both map[string]any and []any, recursing into each element.

Test plan

  • TestStripOriginFromAny_Slice: unit test verifying __origin__ is stripped from objects inside slices
  • TestOrigin_ExampleWithArrayValue: integration test loading a spec with array-valued examples and verifying __origin__ is stripped
  • All existing tests pass: go test ./...

Co-authored-by: Thomas Visser t.visser@hartwigmedicalfoundation.nl

🤖 Generated with Claude Code

stripOriginFromAny only recursed into map[string]any but not []any,
so __origin__ keys inside array elements (e.g. example values with
lists of objects) survived stripping and caused false positive diffs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fenollp fenollp changed the title fix: strip __origin__ from slices in example values openapi3: strip __origin__ from slices in example values Mar 31, 2026
@fenollp fenollp merged commit c132e59 into getkin:master Mar 31, 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.

3 participants