Skip to content

fix: AdditionalOperations handling - #629

Open
sheidkamp wants to merge 1 commit into
pb33f:mainfrom
sheidkamp:addtional_operations_fix
Open

sheidkamp wants to merge 1 commit into
pb33f:mainfrom
sheidkamp:addtional_operations_fix

Conversation

@sheidkamp

Copy link
Copy Markdown

Problem

#628 - additionalOperations from the OpenApi 3.2 spec are dropped during a parse/render round-trip.

Cause

PathItem.Build only set Value on AdditionalOperations, leaving KeyNode and ValueNode nil. NodeReference.IsEmpty() only looks at the nodes, so the high-level model treated the field as empty even when the map had operations in it. Any spec parsed from YAML silently lost its additional operations. They are missing from the high-level PathItem, from GetOperations(), and from rendered output.

Fix

The fix captures the key and value nodes when the map is first created and sets them on the reference. With an additionalOperations container, that's the container's own key and value. With bare method keys there is no container, so it's the first additional operation found.

Testing

The two existing tests in datamodel/high/v3 both parse the YAML through Build() but were hiding the bug.

  • TestPathItem_WithAdditionalOperations replaced what Build() produced with a hand-built low-level reference that had the nodes set, under a comment saying Build() doesn't handle additionalOperations. It does, it just didn't set the nodes. The hand-built block was removed and the test now uses the reference Build() returns.
  • TestPathItem_AdditionalOperations wrapped every assertion in an IsEmpty() check that, due to the bug, prevented the meaningful assertions from running. The check is removed and replaced by an assertion that it is NOT empty instead of skipping the AdditionalOperations validation.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.78%. Comparing base (ca6ca73) to head (d0a0d25).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #629   +/-   ##
=======================================
  Coverage   99.78%   99.78%           
=======================================
  Files         283      283           
  Lines       34456    34460    +4     
=======================================
+ Hits        34382    34386    +4     
  Misses         46       46           
  Partials       28       28           
Flag Coverage Δ
unittests 99.78% <100.00%> (+<0.01%) ⬆️

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

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

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.

1 participant