microsoft / microsoft/typespec

http-server-js - support optional request bodies

Open
#7,677 0 comments 0 reactions 0 assignees View on GitHub
bug emitter:service:js triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Related to https://github.com/microsoft/typespec/issues/6561

For some tests that make a `post` request with an empty request body, the contentType is not being set.

Example test:
https://github.com/microsoft/typespec/blob/bf528cdd57a38bb25e61065c79509a5d5831e631/packages/http-specs/specs/parameters/body-optionality/mockapi.ts#L40-L45

However the __current__ http-server-js emitted code will only run the generated handler for the above scenario if the content-type is present and set to `application/json`.

I'd expect that when the request body is optional, the content-type header may be optional _when the body is not provided_.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.