Add warning when bytes body is used with XML content type#9972
Add warning when bytes body is used with XML content type#9972
bytes body is used with XML content type#9972Conversation
Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
Co-authored-by: markcowl <1054056+markcowl@users.noreply.github.com>
bytes body is used with XML content type
commit: |
|
All changed packages have been documented.
Show changes
|
| ); | ||
| return diagnostics.wrap({ body: undefined, metadata }); | ||
| } | ||
|
|
There was a problem hiding this comment.
I do wonder if this is a little to specific to be both in http library and not just a linting rule. Feel like the same should be true if you try to do that with json or any other structured media no?
|
You can try these changes here
|
|
Hi @@copilot. Your PR has had no update for 30 days and it is marked as a stale PR. If it is not updated within 30 days, the PR will automatically be closed. If you want to refresh the PR, please remove the |
When
bytesis used as a body type with an XML content type (e.g.application/xml), the payload is silently treated as raw binary data rather than structured XML. This adds a warning diagnostic at the@typespec/httplevel so all downstream emitters (OpenAPI3, AutoRest, etc.) surface the issue.packages/http/src/lib.ts— Newbytes-xml-bodywarning diagnosticpackages/http/src/payload.ts— Detection inresolveHttpPayload()after body resolution; matches XML content types via regex (application/xml,text/xml,application/*+xml); walks scalar inheritance chain to catch types extendingbytespackages/http/test/parameters.test.ts— Tests forapplication/xml,text/xml,application/soap+xml, response bodies, and negative case (application/octet-stream)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.