Commit 9099825
Fix optional Content-Type header detection by unifying parameter processing (#9528)
- [x] Understand the issue: The previous fix in PR #9495 added
Content-Type header detection in `type-converter.ts`, but it relies on
`sdkProperty` being passed to `fromSdkType`. The `fromHeaderParameter`
function in `operation-converter.ts` doesn't pass the header parameter
to `fromSdkType`, so the fix doesn't work.
- [x] Fix `fromHeaderParameter` to pass the header parameter `p` to
`fromSdkType` so the Content-Type detection can work
- [x] Unify all parameter-processing functions to pass property instance
to `fromSdkType`:
- `fromQueryParameter`
- `fromPathParameter`
- `fromHeaderParameter`
- `fromBodyParameter`
- `updateMethodParameter`
- [x] Investigated making `sdkProperty` required - not feasible as many
callers have no property context (model base types, array/dict value
types, etc.)
- [x] Run existing tests to verify the fix works (all 177 tests pass)
- [x] Fix CI formatting issues
- [x] Run code review and security checks
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Fix optional contentType issue</issue_title>
> <issue_description>As described in
Azure/azure-sdk-for-net#55300, but the issue
belongs in this repo.</issue_description>
>
> <agent_instructions>The previous [fix
](#9495) does not really fix
the issue entirely.
> Please fix this again following the root cause in this comment:
https://github.com/microsoft/typespec/issues/9494#issuecomment-3822513806</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> <comment_new><author>@ArcturusZhang</author><body>
> I think this is not fixed.
> The fix introduced an extra check to see if it is a content type
header, by checking if the `sdkProperty` is not undefined, but in our
code, when the `fromSdkType` is called converting the method parameters
(for instance
[here](https://github.com/microsoft/typespec/blob/f1a7649b3b53ab7d30488cf7274f813696cdf2d0/packages/http-client-csharp/emitter/src/lib/operation-converter.ts#L482)),
the `sdkProperty` argument is never passed in. Therefore the fix is not
actually running.</body></comment_new>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #9494
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>1 parent f1a7649 commit 9099825
1 file changed
Lines changed: 9 additions & 5 deletions
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
331 | 335 | | |
332 | 336 | | |
333 | 337 | | |
| |||
419 | 423 | | |
420 | 424 | | |
421 | 425 | | |
422 | | - | |
| 426 | + | |
423 | 427 | | |
424 | 428 | | |
425 | 429 | | |
| |||
448 | 452 | | |
449 | 453 | | |
450 | 454 | | |
451 | | - | |
| 455 | + | |
452 | 456 | | |
453 | 457 | | |
454 | 458 | | |
| |||
479 | 483 | | |
480 | 484 | | |
481 | 485 | | |
482 | | - | |
| 486 | + | |
483 | 487 | | |
484 | 488 | | |
485 | 489 | | |
| |||
509 | 513 | | |
510 | 514 | | |
511 | 515 | | |
512 | | - | |
| 516 | + | |
513 | 517 | | |
514 | 518 | | |
515 | 519 | | |
| |||
0 commit comments