Add no-openapi-client-extensions linter rule - #5109
Conversation
|
All changed packages have been documented.
Show changes
|
commit: |
|
You can try these changes here
|
Adds a typespec-azure-core linter rule that flags use of the @typespec/openapi @extension decorator to emit client-altering x-ms-* / x-nullable OpenAPI extensions (e.g. x-ms-long-running-operation, x-ms-pageable, x-ms-enum, x-ms-client-name, x-ms-secret). These extensions only affect the OpenAPI output, so other emitters produce an incorrect representation of the API; the docs point to the equivalent TypeSpec construct for each. Registered in both the data-plane and resource-manager rulesets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 53a7f4f6-90c0-4844-bb8c-e3e62837b21b
The no-openapi rule no longer reports a violation for the @typespec/openapi @extension decorator. Client-altering x-ms-* extensions emitted through @extension are now handled by the dedicated no-openapi-client-extensions rule, so flagging every @extension use here is redundant and over-broad. Updates the tests and rule docs accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 53a7f4f6-90c0-4844-bb8c-e3e62837b21b
155070d to
5631698
Compare
The new @azure-tools/typespec-azure-core/no-openapi-client-extensions linter rule (Azure/typespec-azure#5109) flags uses of the @typespec/openapi @extension decorator that emit client-altering x-ms-* / x-* extensions, because those only affect the OpenAPI output and are ignored by client SDKs and other emitters. This adds #suppress directives at the 150 existing decorator locations (861 diagnostic instances across template instantiations) in 70 specs so they continue to compile once the rule ships. Each directive is placed on the decorated node and records that the usage predates the rule and should migrate to the equivalent TypeSpec construct. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 53a7f4f6-90c0-4844-bb8c-e3e62837b21b
The new @azure-tools/typespec-azure-core/no-openapi-client-extensions linter rule (Azure/typespec-azure#5109) flags uses of the @typespec/openapi @extension decorator that emit client-altering x-ms-* / x-* extensions, because those only affect the OpenAPI output and are ignored by client SDKs and other emitters. This adds #suppress directives at the 150 existing decorator locations (861 diagnostic instances across template instantiations) in 70 specs so they continue to compile once the rule ships. Each directive is placed on the decorated node and records that the usage predates the rule and should migrate to the equivalent TypeSpec construct. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 53a7f4f6-90c0-4844-bb8c-e3e62837b21b
|
PR for spec suppressions: Azure/azure-rest-api-specs#45323 |
📦 Package size report✅ No notable package size changes compared to the base branch. 13 package(s) with no notable change
Packed = gzipped |
catalinaperalta
left a comment
There was a problem hiding this comment.
just a small nit in the docs
…sions.md Co-authored-by: catalinaperalta <9859037+catalinaperalta@users.noreply.github.com>
Summary
Adds a new
typespec-azure-corelinter rule,no-openapi-client-extensions, that flags use of the@typespec/openapi@extensiondecorator to emit client-alteringx-ms-*/x-nullableOpenAPI extensions.These extensions change how clients, SDKs, and the ARM platform interpret an API (long-running, pageable, secret, ARM resource, client name, etc.). When hand-written with the raw
@extensiondecorator they only appear in the OpenAPI output, so every other emitter works from the semantic TypeSpec model and never sees them — producing an incorrect representation of the API. Each has a first-class TypeSpec construct that should be used instead, which the docs enumerate.Extensions flagged:
x-ms-skip-url-encoding,x-ms-enum,x-ms-parameter-grouping,x-ms-parameter-location,x-ms-client-name,x-ms-discriminator-value,x-ms-client-flatten,x-ms-parameterized-host,x-ms-pageable,x-ms-long-running-operation,x-ms-long-running-operation-options,x-nullable,x-ms-internal,x-ms-azure-resource,x-ms-arm-id-details,x-ms-secret.Motivated by the discussion in #3066 (bar use of client-altering extensions).
Changes
packages/typespec-azure-core.linter.tsand in both thedata-planeandresource-managerrulesets.@azure-tools/typespec-azure-coreand@azure-tools/typespec-azure-rulesets.Validation
pnpm build, targeted rule tests (12, all passing), and rulesetsvalidate-rules-definedtests pass.pnpm format,lint, andcspellclean.int:azure-specslabel to be applied to run the External Integration check against all Azure specs.