use-model-request-body
@azure-tools/typespec-azure-resource-manager/use-model-request-bodyRequest bodies must use plain models.
Use a plain model for every Azure Resource Manager request body.
Impact
Section titled “Impact”- Area: API, SDK
Plain model request bodies can evolve by adding optional properties without changing the top-level wire shape. Primitive, union, array, and record bodies cannot gain new fields without a breaking API and generated-SDK change.
A plain model is a TypeSpec model without an indexer. This rule evaluates the authored TypeSpec shape rather than reproducing emitter-specific Swagger schema behavior. Operations without a request body and multipart request bodies are allowed.
Incorrect
Section titled “Incorrect”@postop submit(@body body: string): void;
model ItemList is Array<string>;
@postop submitItems(@body body: ItemList): void;
model Metadata is Record<string>;
@postop submitMetadata(@body body: Metadata): void;Correct
Section titled “Correct”model SubmitRequest { value: string;}
@postop submit(@body body: SubmitRequest): void;
model SubmitItemsRequest { items: string[];}
@postop submitItems(@body body: SubmitItemsRequest): void;Suppression
Section titled “Suppression”Suppress only when required to preserve an existing API; otherwise replace the request body with a model without an indexer.
LintDiff Origin
Section titled “LintDiff Origin”This rule is the idiomatic TypeSpec equivalent of the Swagger validator rule ParametersSchemaAsTypeObject. It intentionally validates TypeSpec model semantics instead of simulating AutoRest’s emitted Swagger schema details.