[Swagger Linter Migration] ConsistentPatchProperties (origin) - #5439
Draft
Yuchao Yan (msyyc) wants to merge 1 commit into
Draft
Conversation
Remove the TCGC/AutoRest scope dependency while retaining native HTTP and model comparison. Add scope-boundary regressions and record partial Swagger equivalence with refreshed corpus evidence. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up source repair to #5399. Promotion exposed that preserving AutoRest-specific
@scopebehavior would make the ARM library depend on client-generator-core, which already references ARM in its build graph. This repair adopts the native TypeSpec contract instead of introducing a downstream dependency or a private-state adapter.The rule no longer constructs a TCGC context or filters operations/properties with
isInScope. It uses compilerProgramand HTTP semantic APIs. Swagger equivalence is explicitly partial, not inferred from project overlap.Original Swagger linter
linter code: ConsistentPatchProperties
linter doc: consistent-patch-properties.md
200, then201, then same-path GET200/201response schemas.How the Swagger linter works
The Spectral selector is
$.paths.*.patch, with references resolved.consistentPatchPropertiesselects the request and response schemas, delegates their recursive comparison todiffSchema, and emits one body-schema diagnostic per reported property path. It does not evaluate TypeSpec decorators. AutoRest has already omitted operations and properties outside its scope before validation.Consequently, a C#-scoped PATCH, request property, or GET fallback can produce no Swagger finding even though it exists in the native HTTP contract. Conversely, a C#-scoped response property can disappear from Swagger and cause a validator finding despite a matching native PATCH subset. Neither side is a bug for these differing contracts.
The earlier migration also recorded status-range differences, an Informatica validator miss, API-version population differences, and emitted-occurrence versus authored-target multiplicity. Those distinctions remain evidence rather than reasons to recreate emitter internals inside a lint.
How the migrated TypeSpec linter works
getAllHttpServicessupplies native HTTP operations. The rule compares PATCH bodies with PATCH response bodies or a same-path GET fallback, preserving exact-code precedence over containing status-code ranges. Recursive model traversal retains inheritance, nullable object handling, JSON encoded names, compiler discriminator metadata, cycle guards, and existing authored diagnostic targets.The only production behavior change is that client/emitter scope no longer removes native operations or properties from this comparison. The existing provider check remains lintdiff's ARM isolation in its mixed ruleset; promotion must assess official-library applicability separately. Other rules still use TCGC, so this PR does not remove package-wide dependencies.
Focused evidence
Direct native regressions compile without AutoRest, including tests that do not load client-generator-core at all. Additional tests load only TCGC's decorator library to prove that its scope metadata does not change native lint outcomes.
scoped-propertyproperties.clientOnlyscoped-get-fallbackdisplayNamescoped-patch-operationextrascoped-response-propertydescriptionabsent from emitted responseSnapshots preserve the comparison differences instead of disguising them as equivalence.
coverageKindis changed topartial. No emitter implementation, harness behavior, official package, or generated corpus data is changed.Migration evidence
See migration.md for the latest full-run counts, project overlap, API-version attribution, compile failures, source revisions, code-backed examples, and evidence limitations. The detailed corpus tables are intentionally not duplicated here.
Promotion status
Promotion remains paused. This source repair changes the previously done rule's contract; the repaired rule must be accepted as done before a new promotion attempt. No ARM-to-TCGC dependency or official-library enablement is introduced by this PR.