Skip to content

[Swagger Linter Migration] GetInOperationName (origin) - #5317

Merged
Yuchao Yan (msyyc) merged 3 commits into
feature/lintdiff-migration-newfrom
feature/lintdiff-get-in-operation-name
Sep 1, 2026
Merged

[Swagger Linter Migration] GetInOperationName (origin)#5317
Yuchao Yan (msyyc) merged 3 commits into
feature/lintdiff-migration-newfrom
feature/lintdiff-get-in-operation-name

Conversation

@msyyc

Copy link
Copy Markdown
Member

Original Swagger linter

GetInOperationName verifies ARM GET operationId naming.

The original rule performs these checks:

  • inspects resolved OpenAPI 2 operationId values under GET operations in both paths and x-ms-paths;
  • accepts IDs that begin with Get or List;
  • accepts noun-prefixed IDs whose verb after an underscore begins with Get or List;
  • applies both patterns case-sensitively; and
  • reports every other non-empty string at the emitted operationId path.

How the Swagger linter works

The Azure ruleset selects $[paths,'x-ms-paths'].*[get][?(@property === 'operationId')] and passes each resolved scalar to a Spectral function. The function returns no result for an empty or non-string value, then applies ^(\w+)_(Get|List) and ^(Get|List). A failure is attached to the selected JSON path, so reused or multiply emitted operations can produce occurrence-level diagnostics.

The migration preserves the case-sensitive naming contract rather than the previous TypeSpec implementation's lowercase source-name approximation. Empty/non-string OpenAPI values do not require a TypeSpec exemption because AutoRest resolves a string operation ID for an emitted semantic operation.

How the migrated TypeSpec linter works

The TypeSpec rule visits semantic operations, resolves their HTTP shape with getHttpOperation, and checks only GET operations. It ignores generic template declarations and instances that have no emitted operation while continuing to check concrete operations created from templates.

For each operation, it reproduces AutoRest operation-ID resolution: explicit @operationId wins; otherwise one AutoRest-scoped TCGC context supplies @clientName and @clientLocation overrides, including AutoRest's falsy empty-location behavior. Interface/namespace prefixes and underscore-segment capitalization match the emitter. The original case-sensitive regexes are then applied to that effective ID, and diagnostics target the authored TypeSpec operation while naming the emitted ID.

Migration evidence

The detailed migration evidence records focused violating/compliant fixtures, report reconciliation, code-backed DataMigration/template/TCGC gap examples, full project lists, diagnostic identities, selected-version policy, compile failures, and remaining uncertainty.

The final pinned full corpus run reached 26/26 same-project overlap with no one-sided projects and 39 aligned diagnostics from each engine. Six TypeSpec compile failures remain explicitly excluded from behavioral comparison. Independent review also identified the empty @clientLocation edge case; the fix has a dedicated fixture and real-service regression checks.

Resolve effective AutoRest operation IDs, including TCGC naming, and ignore non-emitted template artifacts. Add focused fixtures and full-corpus migration evidence.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2e9e55e7-e58a-40a9-811b-5023299a9096

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates GetInOperationName to validate effective AutoRest operation IDs with case-sensitive Get/List semantics.

Changes:

  • Reconstructs emitted IDs using explicit and TCGC naming metadata.
  • Excludes template artifacts.
  • Adds fixtures and migration evidence.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
template-declaration-ignored/validator-diagnostics.json Records validator result.
template-declaration-ignored/tsp-diagnostics.json Records TypeSpec diagnostics.
template-declaration-ignored/output.json Captures emitted Swagger.
template-declaration-ignored/main.tsp Defines template scenario.
template-declaration-ignored/expect.json Declares expected compliance.
GetInOperationName/rule.md Documents rule semantics and scope.
GetInOperationName/migration.md Provides migration evidence.
lowercase-emitted-list/validator-diagnostics.json Records validator violation.
lowercase-emitted-list/tsp-diagnostics.json Records matching lint violation.
lowercase-emitted-list/output.json Captures lowercase emitted ID.
lowercase-emitted-list/main.tsp Defines lowercase-ID scenario.
lowercase-emitted-list/expect.json Declares expected violation.
empty-client-location-compliant/validator-diagnostics.json Records validator compliance.
empty-client-location-compliant/tsp-diagnostics.json Records TypeSpec compliance.
empty-client-location-compliant/output.json Captures emitted ID.
empty-client-location-compliant/main.tsp Tests empty client location.
empty-client-location-compliant/expect.json Declares expected compliance.
emitted-operation-id-compliant/validator-diagnostics.json Records validator compliance.
emitted-operation-id-compliant/tsp-diagnostics.json Records TypeSpec compliance.
emitted-operation-id-compliant/output.json Captures explicit operation ID.
emitted-operation-id-compliant/main.tsp Tests explicit ID precedence.
emitted-operation-id-compliant/expect.json Declares expected compliance.
compliant-with-template/tsp-diagnostics.json Updates emitted ID in warning.
compliant-with-template/main.tsp Reformats template fixture.
client-name-location-compliant/validator-diagnostics.json Records validator compliance.
client-name-location-compliant/tsp-diagnostics.json Records TypeSpec compliance.
client-name-location-compliant/output.json Captures TCGC-resolved ID.
client-name-location-compliant/main.tsp Defines TCGC naming scenario.
client-name-location-compliant/expect.json Declares expected compliance.
src/rules/get-in-operation-name.ts Implements emitted-ID validation.
package.json Adds the TCGC peer dependency.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/typespec-lintdiff/test/fixtures/GetInOperationName/migration.md Outdated
Retain reproducible full-corpus evidence and ensure the TCGC fixture depends on client-name resolution.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: de35f2d0-faec-4f57-8cab-3b8a90dab49c

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated no new comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

packages/typespec-lintdiff/package.json:64

  • This published package change adds a runtime peer dependency and changes lint behavior, but there is no Chronus entry for @azure-tools/typespec-lintdiff. The package workflow requires pnpm change add before opening a PR (packages/typespec-lintdiff/README.md:94-95), so please add the corresponding change description.
    "@azure-tools/typespec-client-generator-core": "workspace:^",

@msyyc
Yuchao Yan (msyyc) marked this pull request as ready for review September 1, 2026 08:38
@msyyc
Yuchao Yan (msyyc) merged commit 93645fc into feature/lintdiff-migration-new Sep 1, 2026
3 checks passed
@msyyc
Yuchao Yan (msyyc) deleted the feature/lintdiff-get-in-operation-name branch September 1, 2026 08:38
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.

2 participants