Skip to content

[Swagger Linter Migration] ListInOperationName (origin) - #5378

Draft
Yuchao Yan (msyyc) wants to merge 3 commits into
feature/lintdiff-migration-newfrom
feature/lintdiff-list-in-operation-name
Draft

[Swagger Linter Migration] ListInOperationName (origin)#5378
Yuchao Yan (msyyc) wants to merge 3 commits into
feature/lintdiff-migration-newfrom
feature/lintdiff-list-in-operation-name

Conversation

@msyyc

Copy link
Copy Markdown
Member

Original Swagger linter

The Swagger rule:

  • inspects GET and POST operations under paths;
  • accepts operation IDs matching Noun_List* or exactly List;
  • diagnoses any operation with x-ms-pageable, regardless of response shape; and
  • otherwise diagnoses a response schema with a value array and no more than one additional property.

How the Swagger linter works

The Spectral selector passes each GET or POST operation object to the rule. The implementation first checks the operation ID against ^((\w+_List\w*)|List)$, then looks for x-ms-pageable. If that extension is absent, it resolves response schemas and looks for the validator's narrow collection shape. Diagnostics are attached to the selected OpenAPI operation, so emitted operation IDs and emitted response structure are the source of truth.

How the migrated TypeSpec linter works

The migrated rule now resolves the operation ID the same way AutoRest does, including explicit @operationId, client names and locations, interface/namespace grouping, and underscore-segment capitalization. The resolver is shared with GetInOperationName.

For GET and POST operations, it detects explicit x-ms-pageable, an inherited @list operation that emits paging because a next link exists, or the validator-equivalent value-array response shape. It avoids internal top-level template instances while retaining authored custom ARM operations, and targets the authored interface when an inherited operation node comes from library code. This fixes legacy operations that emit IDs such as Operations_Get without duplicating diagnostics on standard ARM templates.

Official use-standard-names and ARM templates provide partial coverage, but custom ARM operations remain authorable and the generic naming rule is disabled in the ARM ruleset, so the direct rule remains necessary.

Migration evidence

See ListInOperationName migration evidence for the 12-case emission matrix, full 468-project corpus reconciliation, 53/53 assessable project overlap, 172/172 selected-version emitted-operation attribution, compile failures, and explanations for every raw one-sided result.

Resolve emitted AutoRest operation IDs, mirror Swagger response and verb scope, and document corpus equivalence.

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

Copilot-Session: 4362cc59-54c1-452d-bc77-787dd59e5d6f
…into feature/lintdiff-list-in-operation-name
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.

1 participant