-
Notifications
You must be signed in to change notification settings - Fork 90
[Swagger Linter Migration] LatestVersionOfCommonTypesMustBeUsed #5271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Yuchao Yan (msyyc)
wants to merge
13
commits into
Azure:main
Choose a base branch
from
msyyc:promote-latest-version-common-types-to-arm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8d2c8c5
Promote latest common types lint rule
msyyc 440a51d
Disable latest common types rule by default
msyyc 841b6f3
Address common types rule review
msyyc d8b8176
Apply TypeSpec rule naming conventions
msyyc 09df69b
Update generated linter docs
msyyc 5abd4bf
Address common types rule review feedback
msyyc f15a77b
Avoid global mutation in common types rule
msyyc 9661c68
Update resource-manager.ts
msyyc ea6fd2e
Update use-latest-version-of-common-types.md
msyyc 2e4edd8
Revise title for common types version rule
msyyc dfba9ba
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc 2ad5611
Fix promotion changelog classification
msyyc aeb0eab
Merge main into promote-latest-version-common-types-to-arm
msyyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
.chronus/changes/promote-latest-version-common-types-2026-08-20-14-00-00.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@azure-tools/typespec-azure-resource-manager" | ||
| - "@azure-tools/typespec-azure-rulesets" | ||
| --- | ||
|
|
||
| Add an ARM lint rule that warns when services select or emit older ARM common-types versions instead of the latest available common-types version. |
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
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
121 changes: 121 additions & 0 deletions
121
...typespec-azure-resource-manager/src/rules/use-latest-version-of-common-types.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| --- | ||
| title: "use-latest-version-of-common-types" | ||
| --- | ||
|
|
||
| ```text title="Full name" | ||
| @azure-tools/typespec-azure-resource-manager/use-latest-version-of-common-types | ||
| ``` | ||
|
|
||
| ARM services should use the latest ARM common-types version available in | ||
| `Azure.ResourceManager.CommonTypes.Versions`. This keeps TypeSpec services, | ||
| generated SDKs, and Azure tooling aligned with the current ARM common schemas. | ||
|
|
||
| The rule checks the effective `@armCommonTypesVersion` on each ARM service or | ||
| service version. When the selected version is current, it also checks common | ||
| types reachable from HTTP operation parameters and payloads so older legacy | ||
| symbols are not emitted through an otherwise current API version. | ||
|
|
||
| ## Impact | ||
|
|
||
| - **Area:** API, SDK | ||
|
|
||
| Older ARM common-types versions can expose stale shared schemas or parameters in | ||
| generated API surfaces and SDKs even when newer definitions are available. | ||
|
|
||
| ## Incorrect | ||
|
|
||
| ```tsp | ||
| @armProviderNamespace | ||
| @service(#{ title: "Contoso" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3) | ||
| namespace Microsoft.Contoso; | ||
|
|
||
| enum Versions { | ||
| @useDependency(Azure.ResourceManager.CommonTypes.Versions.v3) | ||
| v2024_01_01: "2024-01-01", | ||
| } | ||
| ``` | ||
|
|
||
| ## Correct | ||
|
|
||
| ```tsp | ||
| @armProviderNamespace | ||
| @service(#{ title: "Contoso" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
|
msyyc marked this conversation as resolved.
|
||
| namespace Microsoft.Contoso; | ||
|
|
||
| enum Versions { | ||
| @useDependency(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| v2024_01_01: "2024-01-01", | ||
| } | ||
| ``` | ||
|
|
||
| ## Incorrect | ||
|
|
||
| This service selects the latest common-types version but still uses a legacy | ||
| common type that resolves to an older common-types file. | ||
|
|
||
| ```tsp | ||
| @armProviderNamespace | ||
| @service(#{ title: "Contoso" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| namespace Microsoft.Contoso; | ||
|
|
||
| enum Versions { | ||
| @useDependency(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| v2024_01_01: "2024-01-01", | ||
| } | ||
|
|
||
| @route("/identity") | ||
| @get | ||
| op getIdentity(): Azure.ResourceManager.Legacy.ManagedServiceIdentityV4; | ||
| ``` | ||
|
|
||
| ## Correct | ||
|
|
||
| Use a common type supported by the selected latest common-types version, or | ||
| remove the legacy reference when the API shape no longer needs it. | ||
|
|
||
| ```tsp | ||
| @armProviderNamespace | ||
| @service(#{ title: "Contoso" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| namespace Microsoft.Contoso; | ||
|
|
||
| enum Versions { | ||
| @useDependency(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| v2024_01_01: "2024-01-01", | ||
| } | ||
|
|
||
| model Widget is TrackedResource<WidgetProperties> { | ||
| ...ManagedServiceIdentityProperty; | ||
|
|
||
| @key("widgetName") | ||
| @segment("widgets") | ||
| @path | ||
| name: string; | ||
| } | ||
|
|
||
| model WidgetProperties { | ||
| description?: string; | ||
| } | ||
|
|
||
| @route("/identity") | ||
| @get | ||
| op getIdentity(): Widget; | ||
|
msyyc marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| ## LintDiff Equivalent | ||
|
|
||
| This rule corresponds to the LintDiff rule | ||
| [LatestVersionOfCommonTypesMustBeUsed](https://github.com/Azure/azure-openapi-validator/blob/main/docs/latest-version-of-common-types-must-be-used.md). | ||
|
|
||
| ## Suppression | ||
|
|
||
| Suppress only when an API must intentionally emit an older ARM common-types | ||
| schema for compatibility and the service team has accepted the API and SDK | ||
| impact. | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.