Fix $ref replaced with inline schema copy (Issue #198)#199
Conversation
ResolveRefProperty replaces $ref with shallow copies for mutation isolation (Issue #146), but this destroyed $ref structure for nested object types like Address. Fix: snapshot $ref properties before rule application and restore them afterwards if no validation constraints were added by rules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@claude review this PR |
|
Claude finished @avgalex's task in 2m 39s —— View job PR Review
SummaryThis PR correctly identifies and fixes the root cause of Issue #198. The snapshot-restore approach is clean and minimally invasive. The fix works well for the primary use case. Correctness AnalysisRoot cause identification is accurate. The fix logic is sound:
BigInteger regression safety: The Issues Found1. The
If a custom type is registered as a // DefaultFluentValidationRuleProvider.cs:124 — not detected by HasValidationConstraintChanges
yield return new FluentValidationRule("EMail")
.WithApply(context => context.Property.Format = "email");2. The However, in OpenAPI 3.0, sibling keywords alongside 3. Null vs empty // OpenApiSchemaCompatibility.cs:361
if (copyReq?.Count != origReq?.Count) return true;If Test Coverage✅ Missing test: a scenario where a Minor Observations
VerdictThe fix is correct and safe for the reported issue. The primary concern is the incomplete |
Address PR #199 review: Email rule sets Format and Pattern rule with UseAllOfForMultipleRules appends to AllOf — both must be detected to prevent silent discard during $ref restoration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Claude finished @avgalex's task in 51s —— View job Review: commit 6d26a4c — Add Format and AllOf checks to HasValidationConstraintChanges
SummaryThis commit correctly addresses both issues raised in the previous review. The implementation is clean and well-targeted. Format check (line 357)if (copy.Format != original.Format) return true;Correct. Placed alongside the other scalar property checks. Handles the AllOf check (lines 365–368)// Check AllOf collection changes (Pattern rule with UseAllOfForMultipleRules)
var copyAllOfCount = copy.AllOf?.Count ?? 0;
var origAllOfCount = original.AllOf?.Count ?? 0;
if (copyAllOfCount != origAllOfCount) return true;Correct for the primary case. Since New test:
|
Summary
SetValidatorwith nested object types (e.g.Address) caused$refto be replaced with inline schema copy in the OpenAPI documentResolveRefProperty(introduced in Add BigInteger support for min/max restrictions (#146) #196 for BigInteger isolation) replaced all$refproperties with copies, destroying reference structure$refproperties before rule application, restore them afterwards if no validation constraints (min/max, minLength, pattern, etc.) were added by rules$refis not restoredTest plan
SetValidator_Should_Preserve_Ref_For_Nested_Objecttest reproducing Issue 7.1.2 replaces schema reference with copy of schema #198SharedRef_Should_Not_Corrupt_Between_Models,BigInteger_InclusiveBetween_Should_Set_MinMax) pass on net10.0🤖 Generated with Claude Code