You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Update x-copy behavior to require single source match per specification OAI/Overlay-Specificatino#PR #150 (#121)
* Initial plan
* Initial commit: Update global.json SDK version
Co-authored-by: baywet <[email protected]>
* Update x-copy behavior to require single source match
- Modified CopyNodes method to enforce exactly one copy source match
- Updated error messages to reflect new validation requirements
- Changed logic to copy same source to all targets (removed sequential pairing)
- Updated existing tests that expected old sequential copy behavior
- Added 4 new unit tests to validate single copy source requirement
- All 53 tests now passing
Co-authored-by: baywet <[email protected]>
* Apply suggestions from code review
* chore: formatting
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: baywet <[email protected]>
Co-authored-by: Vincent Biret <[email protected]>
overlayDiagnostic.Errors.Add(newOpenApiError(GetPointer(index),$"Copy target not found: '{Copy}'"));
170
170
returnfalse;
171
171
}
172
-
if(copyParseResult.Matches.Count<1)
172
+
if(copyParseResult.Matches.Count!=1)
173
173
{
174
-
overlayDiagnostic.Errors.Add(newOpenApiError(GetPointer(index),$"Copy target '{Copy}' must point to at least one JSON node"));
174
+
overlayDiagnostic.Errors.Add(newOpenApiError(GetPointer(index),$"Copy JSON Path '{Copy}' must match exactly one result, but matched {copyParseResult.Matches.Count}"));
overlayDiagnostic.Errors.Add(newOpenApiError(GetPointer(index),$"The number of matches for 'target' ({parseResult.Matches.Count}) and 'x-copy' ({copyParseResult.Matches.Count}) must be the same"));
181
-
returnfalse;
182
-
}
183
178
varmatchValues=parseResult.Matches.Select(static m =>m.Value).ToArray();
184
179
if(matchValues.Any(static m =>misnull))
185
180
{
186
181
overlayDiagnostic.Errors.Add(newOpenApiError(GetPointer(index),$"Target '{Target}' does not point to a valid JSON node"));
187
182
returnfalse;
188
183
}
189
-
varcopyMatchValues=copyParseResult.Matches.Select(static m =>m.Value).ToArray();
190
-
if(copyMatchValues.Any(static m =>misnull))
184
+
if(copyParseResult.Matches[0].Valueis not {}copyMatch)
191
185
{
192
186
overlayDiagnostic.Errors.Add(newOpenApiError(GetPointer(index),$"Copy target '{Copy}' does not point to a valid JSON node"));
0 commit comments