[Swagger Linter Migration] ValidQueryParametersForPointOperations - #5273
[Swagger Linter Migration] ValidQueryParametersForPointOperations#5273Yuchao Yan (msyyc) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 72da97a1-a62c-41e5-b4da-c2a485f735d4
|
All changed packages have been documented.
Show changes
|
📦 Package size report1 package changed size, +1.75 KB (+0.0%) packed overall.
12 package(s) with no notable change
Packed = gzipped |
commit: |
|
You can try these changes here
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8ed00e6d-dd0a-40f7-8871-ee32f0f371fb
|
Finding from the
So the expected follow-up is documentation/evidence only: map |
Original Swagger linters
This promoted TypeSpec rule intentionally covers two Swagger validator rules:
ValidQueryParametersForPointOperations, implemented by the validator's Spectral function for ARM RPC guidelineRPC-Uri-V1-13.ParametersInPointGet, implemented by the validator's Spectral function for ARM RPC guidelineRPC-Get-V1-08.Official TypeSpec rule name:
point-operation-invalid-query-parameter(renamed during promotion to follow TypeSpec linter naming conventions).ValidQueryParametersForPointOperationsperforms these checks:pathsandx-ms-pathsentries./providers/{namespace}followed by one or more resource-type/resource-name pairs; resource names may be{parameters}ordefault.parametersarray and ignores non-query parameters.api-versionand reports every other query parameter independently.ParametersInPointGetis the older production GET-only form of the same policy. It performs these checks:pathsentries.getResourcesPathHierarchyBasedOnResourceType.api-version.parametersarray.How the Swagger linters work
ValidQueryParametersForPointOperationsis invoked over the resolved maps selected by$[paths,'x-ms-paths']. The function loops each URI, applies the sharedisPointOperationregex to the portion beginning at the last/providers/, then loops GET/PUT/PATCH/DELETE and filters each resolved parameter array for query parameters other thanapi-version. Each rejected emitted parameter produces one error located at that operation'sparametersarray.ParametersInPointGetuses a narrower production path: it loops the Swaggerpathsobject, classifies each URI with the ARM resource hierarchy helper, checks only thegetoperation, and reports query parameters other thanapi-version. This is a subset of the broader point-operation rule, so it should map to the same TypeSpec implementation rather than to a second production TypeSpec rule.The broader Swagger rule is
stagingOnly, so normal production AutoRest validation disables it and reports 0 projects. The checked-in migration investigation instead ran the actual Spectral staging rule. Its initial 64-project same-corpus population became 62 projects after restricting both sides to the 462 projects whose TypeSpec compiled, with all 62 projects overlapping. The productionParametersInPointGetrow separately shows 40 Swagger projects, all overlapping the same TypeSpec rule.Raw diagnostic counts are intentionally not one-to-one: Swagger reports emitted operation-parameter occurrences, while a shared TypeSpec parameter declaration can instantiate into several operations and projected versions. The final staging comparison is 321 Swagger diagnostics versus 724 TypeSpec diagnostics, but 62 versus 62 projects with no one-sided projects. The GET-only production comparison is 189 Swagger diagnostics versus the same raw 724 TypeSpec diagnostics, with 40 overlapping Swagger projects and 22 TypeSpec-only projects explained by PUT/PATCH/DELETE coverage from the broader staging rule. The validator also accepts
x-ms-paths, while a clean TypeSpec@sharedRouteequivalent was not included because its emitted?_overload=...disambiguator does not reproduce the upstream rule.Source TypeSpec lintdiff rule
The user-marked done source is
tsp-lintdiff-local-linter/valid-query-parameters-for-point-operationson branchfeature/lintdiff-migration-new, captured at intake commite9d5541c2ef3e354ce1bf6ab3332dfb87620a8d2. The source worktree was clean at intake and had no uncommitted rule changes. This promotion did not modify the lintdiff source, fixtures, snapshots, manifests, or documentation.Destination analysis
This rule belongs in
@azure-tools/typespec-azure-resource-managerbecause validator metadata declaresapplicability: ARM,sources: ["arm"], and the fixture explicitly selects the resource-manager ruleset. Its semantics depend on ARM provider-qualified resource paths and ARM RPC guidance. Azure Core was technically possible because the implementation needs only compiler and HTTP APIs, but placing ARM-only URI policy in the shared data-plane package would expose the wrong dependency and ruleset surface. No equivalent official ARM or Core rule exists.How the promoted TypeSpec linter works
The promoted rule visits TypeSpec operations and resolves each with
getHttpOperation. It filters to GET, PUT, PATCH, and DELETE, then applies the same provider/resource-pair path regex as the Swagger helper to the portion after the last/providers/. For eligible point paths, it examines resolved HTTP parameters, ignores non-query parameters and case-insensitiveapi-version, and reports each additional query parameter on its authorable TypeSpec parameter declaration.This one TypeSpec rule therefore covers both Swagger inputs: it covers
ParametersInPointGetwhen the verb is GET, and it coversValidQueryParametersForPointOperationsacross GET/PUT/PATCH/DELETE. The implementation intentionally does not use ARM operation-kind metadata because that would misclassify list-shaped reads and providerless resource-group DELETE operations that the Swagger path matcher excludes. It also performs no promotion-only deduplication, preserving the done lintdiff rule's operation traversal and source-target behavior. No version projection or semantic behavior was added during promotion.Fixture-to-native test mapping
Each lintdiff fixture became focused native
vitestcoverage using the ARM package tester:extra-query-param-> emits for top-level point GET, PUT, PATCH, and DELETE.nested-extra-query-param-> emits for nested point GET and PUT.multiple-query-params-> preserves one diagnostic per extra query parameter.legacy-action-point-get-> reduces the legacy template to its semantic requirement and verifies that point-path shape, not authoring template, controls eligibility.api-version-only-> accepts point operations with onlyapi-version.list-operation-> accepts collection query parameters.list-shaped-read-> excludes a read-kind path with an unmatched trailing segment.providerless-delete-> excludes a providerless resource-group-style DELETE.No validator snapshots or lintdiff corpus artifacts were copied.
Migration evidence
The focused fixtures, real-service comparison, full-corpus counts, former TypeSpec-only projects, projection fix, diagnostic-cardinality analysis, compile-success population, and remaining uncertainty for
ValidQueryParametersForPointOperationsare documented inmigration.md.The companion
ParametersInPointGetinvestigation confirms the same TypeSpec rule covers every assessable production GET-only Swagger project and explains the 22 TypeSpec-only projects as broader PUT/PATCH/DELETE coverage, not as false positives or a need for another TypeSpec rule: #5210Promotion sync policy
If review identifies a semantic gap, this PR should remain blocked until the user explicitly reopens the lintdiff repair workflow. The immutable source rule must be repaired and revalidated first; semantic changes should not be made only in this promotion PR.