[Swagger Linter Migration] GetCollectionOnlyHasValueAndNextLink - #5358
Draft
Yuchao Yan (msyyc) wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 38d7d6ce-7d4f-4051-bea2-e30ce2a9ac9b
Contributor
|
All changed packages have been documented.
|
Contributor
📦 Package size report✅ No notable package size changes compared to the base branch. 13 package(s) with no notable change
Packed = gzipped |
commit: |
Contributor
|
You can try these changes here
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Original Swagger linter
The original rule performs these checks:
propertiesobjects under200responses for ARM GET operations in bothpathsandx-ms-paths.},operations, ordefault.valueandnextLink.How the Swagger linter works
The Spectral selector traverses resolved Swagger
pathsandx-ms-paths, selects each eligible GET operation'sresponses.200.schema.properties, and passes that object plus its JSON path to the custom function. The function derives the provider tail by splitting a path component containing.and then/; odd tail lengths are treated as point operations and skipped. For collection-shaped tails, it reports when the property map does not contain exactlyvalueandnextLink.The selector's suffix exclusions run against the raw Swagger path key. Therefore,
.../operationsand.../defaultare excluded, while the same paths followed by a query suffix are not. Direct arrays, property-less objects, file responses, and multipart responses have no selectedschema.propertiesnode and are skipped. Because Swagger diagnostics are attached to emitted OpenAPI occurrences, one authored TypeSpec declaration can produce several validator diagnostics; this migration intentionally reports semantic TypeSpec targets instead of reproducing emitted-occurrence duplication.Source TypeSpec lintdiff rule
GetCollectionOnlyHasValueAndNextLinkget-collection-only-has-value-and-next-linkget-collection-only-has-value-and-next-linkfeature/lintdiff-get-collection-only-value-next-linkatefee405b7e91ad3774d6ec0b9e77fffa53c96e51C:\dev\worktrees\lintdiff-get-collection-only-value-next-linkThe inspected source had no uncommitted rule or fixture changes and matched the merged source branch. The user-marked-done lintdiff source was not modified during promotion.
Destination analysis
The rule belongs in
@azure-tools/typespec-azure-resource-manager. Its metadata and fixtures are ARM-only, its semantics depend on provider namespace and ARM collection-path conventions, and its implementation needsresolveProviderNamespace. The validation report also infers the resource-manager ruleset.@azure-tools/typespec-azure-corewas considered but rejected: this is not a shared data-plane response-envelope rule, and moving it to core would either introduce an invalid dependency on the ARM library or weaken the ARM-specific provider and path semantics.How the promoted TypeSpec linter works
The official rule is named
collection-response-only-value-and-next-linkand listens to semantic operations. It:resolveProviderNamespaceto limit evaluation to ARM provider namespaces.getHttpOperationto inspect the projected HTTP GET operation and its raw route.operations/defaultsuffix behavior.200response body while skipping direct arrays, property-less models, file responses, and multipart responses that the Swagger selector cannot reach.valueandnextLinkproperties.The compiler invokes the rule over the active projection, so no separate version-state traversal is needed. It emits at most one semantic diagnostic per operation rather than duplicating diagnostics for every emitted Swagger occurrence. The rule is registered as available but disabled by default in the ARM ruleset.
Fixture-to-native test mapping
extra-collection-propsit("reports an extra property on a collection response")extension-scope-value-onlyit("reports a value-only response on an extension-scope collection path")nextLink.only-value-and-nextlinkit("accepts a response containing only value and nextLink")array-response-bodyit("accepts a named array response body")schema.propertiesexemption for a named array.direct-array-response-bodyit("accepts a direct array response body")record-response-bodyit("accepts a record response body")file-response-bodyit("accepts a file response body")multipart-response-bodyit("accepts a multipart response body")terminal-resource-invalid-responseit("accepts an invalid collection shape on a point path with a query suffix")operations-suffix-invalid-responseit("accepts an invalid collection shape when the raw path ends with operations")operations-query-suffix-invalid-responseit("reports an invalid collection shape when operations is followed by a query suffix")default-suffix-invalid-responseit("accepts an invalid collection shape when the raw path ends with default")default-query-suffix-invalid-responseit("reports an invalid collection shape when default is followed by a query suffix")Migration evidence
The checked-in migration evidence records the focused fixture results, investigated real-service projects, final full-corpus comparison, compile-failure exclusions, emitted-occurrence count differences, and remaining uncertainty.
Validation
pnpm validate:pr --skip-build --skip-test: branch, lint, format, spelling, changeset, and diff checks passedPromotion sync policy
If review finds a semantic gap in the user-marked-done lintdiff source, this promotion must pause until the user explicitly reopens lintdiff repair. Promotion-only adaptations can be fixed here, but the source rule will not be changed implicitly.