Doesn't honor content-type parameter's default setting
- Dominant language
- TypeScript
- Stars
- 14
- Forks
- 5
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 1
Description
For post requests that have no payload, but `content-type` is required, a `requestBody` definition is required so that oats will populate that request header.
This swagger produces the following ts:
```yaml
openapi: 3.0.0
info:
title: Test API
version: 0.0.0
servers:
- url: ''
paths:
/a:
post:
parameters:
- in: header
name: Content-Type
required: true
schema:
type: string
default: 'text/plain; charset=utf-8'
responses:
'200':
description: Success
/b:
post:
requestBody:
required: true
content:
text/plain; charset=utf-8:
schema:
type: object
responses:
'200':
description: Success
```
```ts
export interface PostAParams {
headers: {
"Content-Type": string;
};
}
export const postA = (
params: PostAParams,
options: RequestOptions = {}
): Promise =>
request("POST", "/a", params, options) as Promise;
export const postB = (
params: PostBParams,
options: RequestOptions = {}
): Promise =>
request(
"POST",
"/b",
{ ...params, headers: { "Content-Type": "text/plain; charset=utf-8" } },
options
) as Promise;
```
Contributor guide
Research direction
No source file or test is named. Reproduce the supplied OpenAPI example and compare the generated postA and postB functions, focusing on how a default Content-Type header is handled for a POST without a payload. Done means the generated postA request honors the declared default without requiring callers to provide it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100