-
Notifications
You must be signed in to change notification settings - Fork 90
[Swagger Linter Migration] ParametersSchemaAsTypeObject #5361
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
Open
Yuchao Yan (msyyc)
wants to merge
12
commits into
Azure:main
Choose a base branch
from
msyyc:promote-parameters-schema-as-type-object-to-arm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b5a9b9c
Promote request body object lint rule
msyyc 5cd34b1
Merge remote-tracking branch 'origin/main' into promote-parameters-sc…
msyyc 60cd797
Complete request body rule promotion
msyyc 3e0e8b9
Document request body rule guidance
msyyc 89df075
Address request body rule review
msyyc a491aa9
Merge origin/main into promote-parameters-schema-as-type-object-to-arm
msyyc abb9908
Merge branch 'main' into promote-parameters-schema-as-type-object-to-arm
msyyc d2c8d7b
Merge branch 'main' into promote-parameters-schema-as-type-object-to-arm
msyyc e68b529
Fix promotion changelog classification
msyyc 6b8c017
Merge branch 'main' into promote-parameters-schema-as-type-object-to-arm
msyyc a29fa65
Simplify request body model rule
msyyc 50b037e
Merge branch 'main' into promote-parameters-schema-as-type-object-to-arm
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
8 changes: 8 additions & 0 deletions
8
.chronus/changes/promote-parameters-schema-as-type-object-2026-08-31.md
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,8 @@ | ||
| --- | ||
| changeKind: feature | ||
| packages: | ||
| - "@azure-tools/typespec-azure-resource-manager" | ||
| - "@azure-tools/typespec-azure-rulesets" | ||
| --- | ||
|
|
||
| Add the `request-body-must-be-object` ARM lint rule, migrated from the Swagger `ParametersSchemaAsTypeObject` validator rule and disabled by default in the resource-manager ruleset. | ||
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
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
58 changes: 58 additions & 0 deletions
58
packages/typespec-azure-resource-manager/src/rules/request-body-must-be-object.md
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,58 @@ | ||
| Use an object model for every Azure Resource Manager request body that has an explicit schema type. | ||
|
|
||
| ## Impact | ||
|
|
||
| - **Area:** API, SDK | ||
|
|
||
| Object request bodies can evolve by adding optional properties without changing the top-level wire shape. Primitive and array bodies cannot gain new fields without a breaking API and generated-SDK change. | ||
|
|
||
| Schemas without an explicit type, such as `unknown` and unsupported model unions, are outside this rule's scope. Nullable and singleton unions use their effective emitted schema type, while unions emitted as string or number enums are rejected. Operations without a request body are also allowed. | ||
|
|
||
| ## Incorrect | ||
|
|
||
| ```tsp | ||
| @post | ||
| op submit(@body body: string): void; | ||
|
|
||
| model ItemList is Array<string>; | ||
|
|
||
| @post | ||
| op submitItems(@body body: ItemList): void; | ||
|
|
||
| union ActionMode { | ||
| "fast", | ||
| "safe", | ||
| } | ||
|
|
||
| @post | ||
| op runAction(@body body: ActionMode): void; | ||
| ``` | ||
|
|
||
| ## Correct | ||
|
|
||
| ```tsp | ||
| model SubmitRequest { | ||
| value: string; | ||
| } | ||
|
|
||
| @post | ||
| op submit(@body body: SubmitRequest): void; | ||
|
|
||
| model SubmitItemsRequest { | ||
| items: string[]; | ||
| } | ||
|
|
||
| @post | ||
| op submitItems(@body body: SubmitItemsRequest): void; | ||
|
|
||
| @post | ||
| op submitNullable(@body body: SubmitRequest | null): void; | ||
| ``` | ||
|
|
||
| ## Suppression | ||
|
|
||
| Suppress only when required to preserve an existing API; otherwise replace the request body with an object model. | ||
|
|
||
| ## LintDiff Equivalent | ||
|
|
||
| This rule corresponds to the Swagger validator rule [ParametersSchemaAsTypeObject](https://github.com/Azure/azure-openapi-validator/blob/main/docs/parameters-schema-as-type-object.md). | ||
|
msyyc marked this conversation as resolved.
Outdated
|
||
Oops, something went wrong.
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.