[Swagger Linter Migration] ConsistentPatchProperties (origin) - #5453
Merged
Yuchao Yan (msyyc) merged 6 commits intoSep 11, 2026
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>
…onsistent-patch-properties-native
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…zure/typespec-azure into feature/lintdiff-consistent-patch-properties-native
Respect effective source-name overrides before encoded-name and never filtering; retain native-versus-emitted inheritance evidence. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fix and supporting regression, comparison, and migration coverage are complete with no unresolved blocking issues.
Pull request overview
Repairs inherited never property handling in the native ConsistentPatchProperties linter.
Changes:
- Resolves effective inherited declarations before filtering and encoded-name handling.
- Adds inheritance and encoded-name regression coverage.
- Adds comparison fixtures and updates migration evidence.
File summaries
| File | Reviewed change |
|---|---|
packages/typespec-lintdiff/test/rules/consistent-patch-properties.test.ts |
Adds focused regression tests. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/rule.md |
Documents inheritance behavior and fixtures. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-resource-override/validator-diagnostics.json |
Records validator diagnostics. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-resource-override/tsp-diagnostics.json |
Records native diagnostics. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-resource-override/output.json |
Stores fixture output. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-resource-override/main.tsp |
Defines resource override scenario. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-resource-override/expect.json |
Defines expected results. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-patch-override/validator-diagnostics.json |
Records validator diagnostics. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-patch-override/tsp-diagnostics.json |
Records native diagnostics. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-patch-override/output.json |
Stores fixture output. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-patch-override/main.tsp |
Defines PATCH override scenario. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/never-patch-override/expect.json |
Defines expected results. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/migration.md |
Documents migration findings and validation. |
packages/typespec-lintdiff/test/fixtures/ConsistentPatchProperties/corpus-evidence.json |
Records corpus evidence. |
packages/typespec-lintdiff/src/rules/consistent-patch-properties.ts |
Fixes inherited declaration shadowing. |
Review details
- Files reviewed: 15/15 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Yuchao Yan (msyyc)
marked this pull request as ready for review
September 11, 2026 04:53
Yuchao Yan (msyyc)
requested review from
Mark Cowlishaw (markcowl),
Timothee Guerin (timotheeguerin) and
Jeff Fisher (xirzec)
as code owners
September 11, 2026 04:53
Collect effective authored properties before synthesized discriminator metadata and cover request/response inheritance with native and comparison regressions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
7 tasks
Yuchao Yan (msyyc)
merged commit Sep 11, 2026
7a29831
into
feature/lintdiff-migration-new
3 checks passed
Yuchao Yan (msyyc)
deleted the
feature/lintdiff-consistent-patch-properties-native
branch
September 11, 2026 06:21
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.
Original Swagger linter
linter code: ConsistentPatchProperties
linter doc: consistent-patch-properties.md
allOfproperties and compare property names at the same nesting level.Why this follow-up repair is needed
PR #5439 removed the downstream emitter-context dependency and has merged. Its official ARM promotion exposed two native inheritance bugs, repaired in separate commits here; the unfinished promotion remains separate.
For
Update extends Base { extra?: never; }, the previous walk skipped the derivedneverdeclaration and revivedBase.extra, creating a false positive. The same override in the response incorrectly accepted PATCHextra. A redeclaration changing its encoded name could likewise leave the obsolete base name visible.The resumed promotion then found that synthetic discriminator metadata on a derived model hid an effective inherited authored object encoded to the discriminator name. Moving an inline
payload?: { extra?: string }encoded askindinto a base model incorrectly lost nested comparison. This missed request violations and caused false positives for inherited response objects.How the Swagger linter works
The Spectral rule selects
$.paths.*.patch. It compares the first body parameter schema with the first available response schema in the precedence above. Its recursive helper mergesallOfproperties and follows matching named properties; it reports a missing parent property at the operation-body schema path rather than using TypeSpec source-property locations. Arrays and scalars do not add named element/key comparisons.The four new comparison fixtures expose native/emitted contract differences, not validator defects. AutoRest omits a derived
neverproperty but retains the base viaallOf. For inherited encoded discriminator objects, its derived synthetic string overrides the base object during the validator's schema merge. Each pair produces one native-clean/validator-violation case and one native-violation/validator-clean case. The production lint honors effective TypeSpec authoring rather than simulating emission.How the migrated TypeSpec linter works
Compiler
getProperty(model, property.name)identifies the effective authored declaration before JSON encoded-name resolution andneverfiltering. A shadowed base declaration is skipped even if the derived property contributes no payload property.The helper now collects the complete effective authored shape before adding missing synthetic discriminators. Authored properties, including inherited encoded objects, take precedence. Effective source-name lookup also prevents synthesizing an extra discriminator when an inherited authored discriminator name is encoded differently. Genuine synthetic discriminators remain supported, and
neveroverrides do not resurrect shadowed nested shapes.The rule still uses the native HTTP service graph, PATCH/GET response-body selection (including status-code ranges after exact matches), compiler model/nullable/discriminator metadata, and recursive same-level comparison. Diagnostics retain authored property/model targets and existing multiplicity; no new deduplication or version projection is introduced. The lintdiff-only provider isolation guard is unchanged.
Fourteen added native cases cover request/response
neveroverrides, intermediate inheritance, encoded-name redeclarations, inherited/inline discriminator objects, differently encoded discriminator source names, and genuine synthetic metadata. Existing scope differences remain documented; no emitter, TCGC, or OpenAPI dependency was added to production logic.Migration evidence
ConsistentPatchProperties migration evidence records both inheritance repairs, their native/emitted matrix, focused comparisons, the final full-corpus rerun, exact diagnostic-multiset comparison, one-sided project explanations, compile exclusions, and remaining Informatica/version-attribution uncertainty.
Swagger equivalence remains partial. Unchanged corpus findings do not replace the supported native-shape regressions that exposed these bugs.
Validation and scope
The source package build, changed-file oxlint/formatting, 23 native rule cases, and all 22 comparison cases passed. Snapshots were regenerated and checked without updates, including after formatting. The final full corpus completed on September 11 at 13:23 +08:00; its six compile exclusions remain explicitly recorded in the linked evidence.
Generated corpus data was retained outside the repository and restored before publication. This PR changes only the rule, directly related tests/fixtures, and rule-local migration evidence. Promotion may resume from the final reviewed source; neither the unfinished official copy nor unrelated rules were changed here.