Skip to content

[Swagger Linter Migration] GetInOperationName - #5364

Open
Yuchao Yan (msyyc) wants to merge 7 commits into
Azure:mainfrom
msyyc:promote-lintdiff-get-in-operation-name-to-tcgc
Open

[Swagger Linter Migration] GetInOperationName#5364
Yuchao Yan (msyyc) wants to merge 7 commits into
Azure:mainfrom
msyyc:promote-lintdiff-get-in-operation-name-to-tcgc

Conversation

@msyyc

@msyyc Yuchao Yan (msyyc) commented Sep 1, 2026

Copy link
Copy Markdown
Member

Original Swagger linter

The Swagger rule checks GET operation IDs for a Get or List verb, either directly or after an operation-group prefix. Its underlying purpose is to ensure generated SDK methods clearly communicate whether they retrieve one resource or list several resources.

Promoted TypeSpec rule

The promoted @azure-tools/typespec-client-generator-core/get-operation-name rule validates the SDK method name modeled by TCGC rather than reconstructing an AutoRest-specific Swagger operationId.

The rule:

  • visits concrete GET operations and ignores template declarations and non-GET operations;
  • resolves the unscoped/default TCGC method name, including an unscoped @clientName override;
  • ignores @operationId, client/operation-group location, and emitter-scoped name overrides because those do not define the common TCGC SDK method name;
  • accepts get or list case-insensitively so the language-neutral TCGC name can use its normal lower-camel casing;
  • reports one diagnostic on the TypeSpec operation.

This keeps the rule in TCGC, where the generated SDK API name is modeled, without introducing an AutoRest dependency or duplicating AutoRest's operation-ID resolver. The rule is registered but disabled by default in both Azure data-plane and resource-manager rulesets.

Migration note

This is an intent-preserving migration rather than a byte-for-byte check of the Swagger operationId. Explicit @operationId values and operation-group prefixes can therefore differ from the value checked by the native rule. Those differences are intentional: the native rule enforces the generated SDK method-name guideline at the TCGC abstraction layer.

Validation

  • TCGC dependency-closure and package builds
  • Focused native rule tests: 11 passed
  • TCGC lint
  • TCGC documentation regeneration
  • Repository formatting and linting
  • git diff --check

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

Copilot-Session: bd1f28a6-d04a-4d89-99d2-f39e205d67e9
@msyyc Yuchao Yan (msyyc) added the int:azure-specs Run integration tests against azure-rest-api-specs label Sep 1, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added lib:tcgc Issues for @azure-tools/typespec-client-generator-core library meta:website TypeSpec.io updates linter Issues related to linter rules labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @azure-tools/typespec-azure-rulesets
  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-azure-rulesets - internal ✏️

Register the @azure-tools/typespec-client-generator-core get-operation-name rule as disabled in,> the client SDK ruleset.

@azure-tools/typespec-client-generator-core - feature ✏️

Add the get-operation-name rule for GET SDK method names.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

📦 Package size report

✅ No notable package size changes compared to the base branch.

13 package(s) with no notable change
Package Packed (base → head) Δ Packed Unpacked (base → head) Δ Unpacked
@azure-tools/typespec-client-generator-core 238.21 KB → 238.34 KB +132 B (+0.1%) 1.28 MB → 1.28 MB +459 B (+0.0%)
@azure-tools/typespec-java 13.51 MB → 13.51 MB -77 B (-0.0%) 15.04 MB → 15.04 MB
@azure-tools/typespec-azure-rulesets 5.34 KB → 5.42 KB +75 B (+1.4%) 33.37 KB → 33.63 KB +270 B (+0.8%)
@azure-tools/azure-http-specs 146.76 KB → 146.76 KB 1.16 MB → 1.16 MB
@azure-tools/typespec-autorest 81.23 KB → 81.23 KB 396.61 KB → 396.61 KB
@azure-tools/typespec-autorest-canonical 7.42 KB → 7.42 KB 26.00 KB → 26.00 KB
@azure-tools/typespec-azure-core 130.84 KB → 130.84 KB 709.84 KB → 709.84 KB
@azure-tools/typespec-azure-portal-core 42.46 KB → 42.46 KB 193.15 KB → 193.15 KB
@azure-tools/typespec-azure-resource-manager 177.33 KB → 177.33 KB 1.07 MB → 1.07 MB
@azure-tools/typespec-go 261.39 KB → 261.39 KB 1.34 MB → 1.34 MB
@azure-tools/typespec-metadata 15.91 KB → 15.91 KB 62.26 KB → 62.26 KB
@azure-tools/typespec-python 42.22 KB → 42.22 KB 164.91 KB → 164.91 KB
@azure-tools/typespec-ts 540.59 KB → 540.59 KB 2.60 MB → 2.60 MB

Packed = gzipped .tgz published to npm. Unpacked = total extracted size. 🆕 added, 🗑️ removed. Packages from the core/ submodule are not included.
🔴 grew · 🟢 shrank — only changes of at least 512 B and 0.5% are marked.

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-azure-rulesets@5364
npm i https://pkg.pr.new/@azure-tools/typespec-client-generator-core@5364

commit: cd6203a

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

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.

🟡 Changes recommended

Required documentation and resolver coverage are incomplete, and one release entry identifies the wrong package.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Promotes the Swagger GetInOperationName validation into TCGC.

Changes:

  • Adds and tests the get-operation-name rule.
  • Registers it disabled by default in both Azure rulesets.
  • Adds documentation and release entries.
File summaries
File Description
website/.../reference/linter.md Lists the new rule.
packages/.../test/tester.ts Loads OpenAPI test support.
packages/.../get-operation-name.test.ts Adds rule tests.
packages/.../get-operation-name.rule.ts Implements operation-ID validation.
packages/.../get-operation-name.md Documents the rule.
packages/.../src/linter.ts Registers the rule.
packages/.../README.md Lists the rule publicly.
packages/.../resource-manager.ts Registers it disabled for ARM.
packages/.../data-plane.ts Registers it disabled for data plane.
.chronus/...-tcgc.md Records the TCGC feature.
.chronus/...-rulesets.md Records ruleset registration.
Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 3
  • Review effort level: Balanced

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

Comment thread packages/typespec-client-generator-core/test/rules/get-operation-name.test.ts Outdated
Comment thread .chronus/changes/promote-get-in-operation-name-rulesets.md Outdated
Comment thread packages/typespec-client-generator-core/src/rules/get-operation-name.md Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

The reviewed implementation, tests, documentation, and disabled-by-default registrations have no unresolved issues.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

Use the unscoped TCGC library name instead of reconstructing AutoRest operation IDs.

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

Copilot-Session: 36f23ec9-2dba-44e6-a727-a26129cae550
Comment thread .chronus/changes/promote-get-in-operation-name-rulesets.md Outdated
Comment thread packages/typespec-azure-rulesets/src/rulesets/data-plane.ts Outdated
return;
}

const operationName = getLibraryName(tcgcContext, operation, AllScopes);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this actually need tcgc at all, is that not just operation.name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Kept the TCGC resolution intentionally and clarified it in 7118644. An unscoped @clientName changes the generated SdkServiceMethod.name, while operation.name remains the TypeSpec source name. getLibraryName(tcgcContext, operation, AllScopes) validates that common SDK method name and excludes emitter-specific overrides.

Scope the disabled rule to the client SDK ruleset and simplify its diagnostic while retaining TCGC SDK name resolution.

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

Copilot-Session: 36f23ec9-2dba-44e6-a727-a26129cae550
@@ -8,6 +8,8 @@ export default {
"@azure-tools/typespec-client-generator-core/csharp-model-suffix": true,
},
disable: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think its better to have in enable as false. Makes upgrading after just toggling it. Disabled should more be used in tspconfig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also just thinking about this being a tcgc rule was that supposed to apply to data plane too or just ARM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

int:azure-specs Run integration tests against azure-rest-api-specs lib:tcgc Issues for @azure-tools/typespec-client-generator-core library linter Issues related to linter rules meta:website TypeSpec.io updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants