Repository navigation
[Swagger Linter Migration] LatestVersionOfCommonTypesMustBeUsed (origin) #5203
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
Merged
Yuchao Yan (msyyc)
merged 9 commits into
feature/lintdiff-migration-new
from
feature/lintdiff-latest-version-common-types
Aug 20, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a97eba7
Fix latest common types lint parity
msyyc 82e7dd8
Require rule-specific lintdiff branches
msyyc bedafe2
Clarify stale common types validator map
msyyc fbd5fd2
Improve lint rule PR guidance
msyyc 95f4fb1
Clarify legacy common type diagnostics
msyyc 95de8bc
Address latest common types review findings
msyyc 2de7144
Respect payload visibility in common types lint
msyyc 953b03b
Delete .github/skills/develop-lintdiff-rule/SKILL.md
msyyc be31081
Merge branch 'feature/lintdiff-migration-new' into feature/lintdiff-l…
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
366 changes: 347 additions & 19 deletions
366
packages/typespec-lintdiff/src/rules/latest-version-of-common-types-must-be-used.ts
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.../test/fixtures/LatestVersionOfCommonTypesMustBeUsed/legacy-location-parameter/expect.json
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 @@ | ||
| { "violation": true } |
36 changes: 36 additions & 0 deletions
36
...iff/test/fixtures/LatestVersionOfCommonTypesMustBeUsed/legacy-location-parameter/main.tsp
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,36 @@ | ||
| import "../../lib/imports.tsp"; | ||
| using TypeSpec.Http; | ||
| using TypeSpec.Rest; | ||
| using TypeSpec.Versioning; | ||
| using Azure.ResourceManager; | ||
|
|
||
| @armProviderNamespace | ||
| @service(#{ title: "Test Service" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(CommonTypes.Versions.v6) | ||
| namespace Microsoft.TestService; | ||
|
|
||
| enum Versions { | ||
| @useDependency(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| v2024_01_01: "2024-01-01", | ||
| } | ||
|
|
||
| @route("/subscriptions/{subscriptionId}/providers/Microsoft.TestService") | ||
| interface Operations { | ||
| @get | ||
| @route("/locations/{location}/widgets") | ||
| listByLocation( | ||
| ...SubscriptionIdParameter, | ||
| ...LocationParameter, | ||
| ): { | ||
| @body body: WidgetListResult; | ||
| }; | ||
| } | ||
|
|
||
| model WidgetListResult { | ||
| value: Widget[]; | ||
| } | ||
|
|
||
| model Widget { | ||
| name: string; | ||
| } |
92 changes: 92 additions & 0 deletions
92
.../test/fixtures/LatestVersionOfCommonTypesMustBeUsed/legacy-location-parameter/output.json
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,92 @@ | ||
| { | ||
| "swagger": "2.0", | ||
| "info": { | ||
| "title": "Test Service", | ||
| "version": "2024-01-01", | ||
| "x-typespec-generated": [ | ||
| { | ||
| "emitter": "@azure-tools/typespec-autorest" | ||
| } | ||
| ] | ||
| }, | ||
| "schemes": [ | ||
| "https" | ||
| ], | ||
| "host": "management.azure.com", | ||
| "produces": [ | ||
| "application/json" | ||
| ], | ||
| "consumes": [ | ||
| "application/json" | ||
| ], | ||
| "security": [ | ||
| { | ||
| "azure_auth": [ | ||
| "user_impersonation" | ||
| ] | ||
| } | ||
| ], | ||
| "securityDefinitions": { | ||
| "azure_auth": { | ||
| "type": "oauth2", | ||
| "description": "Azure Active Directory OAuth2 Flow.", | ||
| "flow": "implicit", | ||
| "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", | ||
| "scopes": { | ||
| "user_impersonation": "impersonate your user account" | ||
| } | ||
| } | ||
| }, | ||
| "tags": [], | ||
| "paths": { | ||
| "/subscriptions/{subscriptionId}/providers/Microsoft.TestService/locations/{location}/widgets": { | ||
| "get": { | ||
| "operationId": "Operations_ListByLocation", | ||
| "parameters": [ | ||
| { | ||
| "$ref": "../../../../../common-types/resource-management/v6/types.json#/parameters/SubscriptionIdParameter" | ||
| }, | ||
| { | ||
| "$ref": "../../../../../common-types/resource-management/v5/types.json#/parameters/LocationParameter" | ||
| } | ||
| ], | ||
| "responses": { | ||
| "200": { | ||
| "description": "The request has succeeded.", | ||
| "schema": { | ||
| "$ref": "#/definitions/WidgetListResult" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "definitions": { | ||
| "Widget": { | ||
| "type": "object", | ||
| "properties": { | ||
| "name": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "name" | ||
| ] | ||
| }, | ||
| "WidgetListResult": { | ||
| "type": "object", | ||
| "properties": { | ||
| "value": { | ||
| "type": "array", | ||
| "items": { | ||
| "$ref": "#/definitions/Widget" | ||
| } | ||
| } | ||
| }, | ||
| "required": [ | ||
| "value" | ||
| ] | ||
| } | ||
| }, | ||
| "parameters": {} | ||
| } |
72 changes: 72 additions & 0 deletions
72
...tures/LatestVersionOfCommonTypesMustBeUsed/legacy-location-parameter/tsp-diagnostics.json
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,72 @@ | ||
| [ | ||
| { | ||
| "code": "tsp-lintdiff-local-linter/latest-version-of-common-types-must-be-used", | ||
| "severity": "warning", | ||
| "message": "This API version already selects the latest ARM common-types version 'v6', but the common-type parameter 'LocationParameter' resolves to 'types.json' version 'v5'. Replace the TypeSpec usage that produces this legacy reference with a common type supported in 'v6'." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-resource-manager/missing-operations-endpoint", | ||
| "severity": "warning", | ||
| "message": "Arm namespace TestService is missing the Operations interface. Add \"interface Operations extends Azure.ResourceManager.Operations {}\"." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-core/documentation-required", | ||
| "severity": "warning", | ||
| "message": "The Model named 'WidgetListResult' should have a documentation or description, use doc comment /** */ to provide it." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-core/documentation-required", | ||
| "severity": "warning", | ||
| "message": "The ModelProperty named 'value' should have a documentation or description, use doc comment /** */ to provide it." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-core/documentation-required", | ||
| "severity": "warning", | ||
| "message": "The Model named 'Widget' should have a documentation or description, use doc comment /** */ to provide it." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-core/documentation-required", | ||
| "severity": "warning", | ||
| "message": "The ModelProperty named 'name' should have a documentation or description, use doc comment /** */ to provide it." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-resource-manager/arm-resource-interface-requires-decorator", | ||
| "severity": "warning", | ||
| "message": "Each resource interface must have an @armResourceOperations decorator." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-core/operation-missing-api-version", | ||
| "severity": "warning", | ||
| "message": "Operation is missing an api version parameter." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-core/documentation-required", | ||
| "severity": "warning", | ||
| "message": "The Operation named 'listByLocation' should have a documentation or description, use doc comment /** */ to provide it." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-resource-manager/arm-resource-operation", | ||
| "severity": "warning", | ||
| "message": "All Resource operations must use an api-version parameter. Please include Azure.ResourceManager.ApiVersionParameter in the operation parameter list using the spread (...ApiVersionParameter) operator, or using one of the common resource parameter models." | ||
| }, | ||
| { | ||
| "code": "@azure-tools/typespec-azure-resource-manager/arm-resource-operation", | ||
| "severity": "warning", | ||
| "message": "Resource GET operation must be decorated with @armResourceRead or @armResourceList." | ||
| }, | ||
| { | ||
| "code": "tsp-lintdiff-local-linter/get-collection-only-has-value-and-next-link", | ||
| "severity": "warning", | ||
| "message": "Get endpoints for collections of resources must only have the `value` and `nextLink` properties in their model." | ||
| }, | ||
| { | ||
| "code": "tsp-lintdiff-local-linter/xms-examples-required", | ||
| "severity": "warning", | ||
| "message": "Please provide x-ms-examples describing minimum/maximum property set for response/request payloads for operations." | ||
| }, | ||
| { | ||
| "code": "tsp-lintdiff-local-linter/xms-pageable-for-list-calls", | ||
| "severity": "warning", | ||
| "message": "ARM GET operations on list paths that return collection payloads should define x-ms-pageable metadata." | ||
| } | ||
| ] |
15 changes: 15 additions & 0 deletions
15
...LatestVersionOfCommonTypesMustBeUsed/legacy-location-parameter/validator-diagnostics.json
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,15 @@ | ||
| [ | ||
| { | ||
| "code": "LatestVersionOfCommonTypesMustBeUsed", | ||
| "message": "Use the latest version v6 of types.json.", | ||
| "path": [ | ||
| "paths", | ||
| "/subscriptions/{subscriptionId}/providers/Microsoft.TestService/locations/{location}/widgets", | ||
| "get", | ||
| "parameters", | ||
| "1", | ||
| "$ref" | ||
| ], | ||
| "severity": 0 | ||
| } | ||
| ] |
1 change: 1 addition & 0 deletions
1
...ff/test/fixtures/LatestVersionOfCommonTypesMustBeUsed/legacy-managed-identity/expect.json
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 @@ | ||
| { "violation": true } |
41 changes: 41 additions & 0 deletions
41
...tdiff/test/fixtures/LatestVersionOfCommonTypesMustBeUsed/legacy-managed-identity/main.tsp
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,41 @@ | ||
| import "../../lib/imports.tsp"; | ||
| using TypeSpec.Http; | ||
| using TypeSpec.Rest; | ||
| using TypeSpec.Versioning; | ||
| using Azure.ResourceManager; | ||
|
|
||
| @armProviderNamespace | ||
| @service(#{ title: "Test Service" }) | ||
| @versioned(Versions) | ||
| @armCommonTypesVersion(CommonTypes.Versions.v6) | ||
| namespace Microsoft.TestService; | ||
|
|
||
| enum Versions { | ||
| @useDependency(Azure.ResourceManager.CommonTypes.Versions.v6) | ||
| v2024_01_01: "2024-01-01", | ||
| } | ||
|
|
||
| model Widget is TrackedResource<WidgetProperties> { | ||
| ...Azure.ResourceManager.Legacy.ManagedServiceIdentityV4Property; | ||
|
|
||
| @key("widgetName") | ||
| @segment("widgets") | ||
| @doc("The name of the widget") | ||
| @path | ||
| @pattern("^[a-zA-Z0-9_-]+$") | ||
| name: string; | ||
| } | ||
|
|
||
| @doc("Widget resource properties.") | ||
| model WidgetProperties { | ||
| @doc("Widget description.") | ||
| description?: string; | ||
| } | ||
|
|
||
| interface Operations extends Azure.ResourceManager.Operations {} | ||
|
|
||
| @armResourceOperations | ||
| interface Widgets { | ||
| get is ArmResourceRead<Widget>; | ||
| createOrUpdate is ArmResourceCreateOrReplaceAsync<Widget>; | ||
| } |
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.