[Swagger Linter Migration] ParametersInPost - #5281
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
All changed packages have been documented.
Show changes
|
📦 Package size report2 packages changed size, +6.23 KB (+0.0%) packed overall.
11 package(s) with no notable change
Packed = gzipped |
commit: |
|
You can try these changes here
|
catalinaperalta
left a comment
There was a problem hiding this comment.
overall lgtm, left a question about the api version casing but we could improve it later on
| }, | ||
| }); | ||
|
|
||
| function isApiVersionParameter(name: string): boolean { |
There was a problem hiding this comment.
this is defined in use-api-version.ts rule can we share the helper(move it to common place)
There was a problem hiding this comment.
I kept these helpers separate because they answer different questions. This rule checks the exact serialized HTTP query name (api-version) for Swagger parity, while use-api-version.ts checks whether a model property originates from the common-types ApiVersionParameter. Sharing that helper would change this rule's semantics.
There was a problem hiding this comment.
still should at least share it across the new rules you add
Co-authored-by: Mark Cowlishaw <1054056+markcowl@users.noreply.github.com>
…rameters-in-post.ts Co-authored-by: Mark Cowlishaw <1054056+markcowl@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Timothee Guerin (@timotheeguerin) / Mark Cowlishaw (@markcowl) Thanks for your review. I updated PR with your suggestions and pls help take a review again. |
Original Swagger linter
The original rule checks:
RPC-POST-V1-05).in === "query".api-version.How the Swagger linter works
The Spectral function receives the Swagger POST operation
parametersarray. It returns no diagnostics when the value is not an array or is empty. Otherwise it filters the operation parameters withparam.in === "query" && param.name !== "api-version", then emits one diagnostic per matching parameter. The diagnostic path is the Spectral context path for the operation parameters rather than the individual TypeSpec source parameter.The Swagger rule reports emitted OpenAPI occurrences, so its raw diagnostic cardinality can differ from a semantic TypeSpec rule. The migration evidence notes one known cardinality skew in HybridConnectivity where Swagger emits two POST parameter occurrences while TypeSpec reports four semantic source locations for
expiresin; that is not a project coverage gap.Source TypeSpec lintdiff rule
ParametersInPostparameters-in-postparameters-in-postfeature/lintdiff-parameters-in-poste56688697d812f0c46ac0a5c15dc00aa038d708eC:\dev\worktrees\typespec-azure-lintdiff-parameters-in-postThe user-marked done source rule was not modified during promotion.
Destination analysis
Selected package:
@azure-tools/typespec-azure-resource-manager.Evidence:
ParametersInPostapplies to Resource Manager (ARM).applicability: ARM,sources: ["arm"], severityerror, and RPC codeRPC-POST-V1-05.isArmProviderNamespace.docs/validate-report.mdinferred the fixture rows asresource-manager.Plausible alternative:
@azure-tools/typespec-azure-core, but that would either over-scope an ARM-only RPC rule to data-plane services or require a rewrite that removes the ARM provider namespace boundary. The ARM package keeps the dependency direction correct and matches the source semantics.How the promoted TypeSpec linter works
The promoted rule is
@azure-tools/typespec-azure-resource-manager/no-query-parameters-in-post. It registers in the ARM linter and the resource-manager ruleset.For each operation, it:
isArmProviderNamespaceto keep the rule scoped to ARM provider namespaces.getHttpOperationto inspect the HTTP verb and parameters.api-version.parameter.param) and includes the query name in the diagnostic message.Intentional promotion adaptation: the official rule uses an exact
name === "api-version"exemption to match the original Swagger validator. During final review, the lintdiff source was found to use a case-insensitive helper; the source branch remains unchanged, and this PR documents the sync note below.Fixture-to-native test mapping
query-param-in-post-> emits one warning formodeon an ARM POST resource action.multiple-query-params-> emits one warning each formodeandformaton the same ARM POST operation.non-resource-post-query-> emits a warning for$filteron a non-resource ARM POST operation.api-version-only-> remains valid when the only query parameter is the standardapi-versionsupplied by ARM templates.@query("API-Version")emits a warning, matching the Swagger validator's exact-nameapi-versionexemption.Migration evidence
Migration evidence is captured in the source branch's
migration.md, including the focused tests, real-service project comparison, latest full-corpus counts, one-sided project explanations, compile failures, diagnostic cardinality notes, and final uncertainty statement.Validation
Targeted validation completed:
pnpm -r --filter "@azure-tools/typespec-azure-resource-manager..." buildpnpm --filter @azure-tools/typespec-azure-resource-manager exec vitest run test/rules/no-query-parameters-in-post.test.ts(6 tests)pnpm --filter @azure-tools/typespec-azure-resource-manager buildpnpm --filter @azure-tools/typespec-azure-resource-manager lintpnpm --filter @azure-tools/typespec-azure-resource-manager regen-docspnpm run format:checkpnpm --filter "@azure-tools/typespec-azure-website..." run buildpnpm --filter @azure-tools/typespec-azure-rulesets buildpnpm --filter @azure-tools/typespec-azure-rulesets testpnpm --filter @azure-tools/typespec-azure-resource-manager test(passed after rerun; the first full-package run timed out once in existingtest/enforce-constraint.test.ts, and that test file passed when rerun directly)git diff --checkValidation blocker
pnpm validate:prwas run with a bounded wait. It completed step 1,Branch is up to date, in 3.7s, then produced no further progress during the 5-minute bound. Because the targeted package, docs, website, rulesets, formatting, and diff validations above passed, the stalled broad pre-PR run was stopped and treated as an environmental/pre-existing validation blocker.Promotion sync policy
The lintdiff source branch remains the source of truth for the migration PR and was not changed during this promotion. If reviewers decide the source lintdiff rule must also use exact
api-versionmatching, that should be handled by explicitly reopening lintdiff repair forParametersInPost; this promotion PR should stay synchronized with the approved source or be blocked until that repair is completed.This new ARM rule could affect existing Azure service specs, so the
int:azure-specslabel is appropriate.