conflicting-multipart-model-usage
@azure-tools/typespec-client-generator-core/conflicting-multipart-model-usageSeverity: error
This diagnostic is issued when the same model is used as both multipart/form-data input and regular body input such as JSON or XML. Those request bodies have different wire shapes and cannot safely share one SDK model.
Impact
Section titled “Impact”- Area: Request body model generation. Blocks safe SDK input-model generation because one model would need incompatible multipart and regular-body serialization behavior.
- Not affected: The individual TypeSpec operations still describe their request body content types.
❌ Incorrect Usage
Section titled “❌ Incorrect Usage”@service(#{ title: "Test Service" })namespace TestService;
model MultiPartRequest { id: HttpPart<string>; profileImage: HttpPart<bytes>;}
@putop jsonUse(@body multipartBody: MultiPartRequest): NoContentResponse;
@postop multipartUse( @header contentType: "multipart/form-data", @multipartBody body: MultiPartRequest, // `MultiPartRequest` is also used as a regular body): NoContentResponse;Diagnostic Message
Section titled “Diagnostic Message”TCGC reports:
Model 'MultiPartRequest' cannot be used as both multipart/form-data input and regular body input. You can create a separate model with name 'model MultiPartRequestFormData' extends MultiPartRequest {}✅ How to Fix
Section titled “✅ How to Fix”Create a separate form-data model, such as <ModelName>FormData, and use each model only for its matching body kind.
using TypeSpec.Http;
@service(#{ title: "Test Service" })namespace TestService;
model JsonRequest { id: string; profileImage: bytes;}
model MultiPartRequestFormData { id: HttpPart<string>; profileImage: HttpPart<bytes>;}
@putop jsonUse(@body body: JsonRequest): NoContentResponse;
@postop multipartUse( @header contentType: "multipart/form-data", @multipartBody body: MultiPartRequestFormData,): NoContentResponse;