application/json content type is not set for body that only has one field
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- api
Research direction
The issue is in the generated client code where endpoints with a single-field body are missing the type: ContentType.Json parameter. Look at the code generator that produces these TypeScript functions, likely in a file handling request template generation. Compare how endpoints with one field vs. multiple fields are processed. The fix is to ensure the type argument is included for all JSON body requests. Test by regenerating the client for an OpenAPI spec with a single-field body endpoint and verifying the ContentType is set.
Written by the indexing model from the issue text.
Description
this is one of our endpoints with a body that may accept two fields:
/**
* No description
*
* @tags Custodians
* @name PostSecuredCustodiansCreate
* @request POST:/v1/secured/custodians/create
*/
postSecuredCustodiansCreate = (
body: {
name: string;
notes?: string;
},
params: RequestParams = {}
) =>
this.request<
{
status: 'ok';
data: {
id: string;
/** @format date-time */
createdAt: string;
/** @format date-time */
updatedAt: string;
name: string;
notes?: string;
};
},
any
>({
path: `/v1/secured/custodians/create`,
method: 'POST',
body: body,
type: ContentType.Json,
format: 'json',
...params,
});
and in the same file, any endpoint that requires one field has missing type in request options:
/**
* No description
*
* @tags Custodians
* @name PostSecuredCustodiansGet
* @request POST:/v1/secured/custodians/get
*/
postSecuredCustodiansGet = (
body: {
id: string;
},
params: RequestParams = {}
) =>
this.request<
{
status: 'ok';
data: {
id: string;
/** @format date-time */
createdAt: string;
/** @format date-time */
updatedAt: string;
name: string;
notes?: string;
};
},
any
>({
path: `/v1/secured/custodians/get`,
method: 'POST',
body: body,
format: 'json',
...params,
}); // `type` arg is missing from here, client tries to send the body as text
- Dominant language
- TypeScript
- Stars
- 4.1k
- Forks
- 436
- Avg merge
- 9d 7h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from acacode/swagger-typescript-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
acacode/swagger-typescript-api#1821 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
acacode/swagger-typescript-api#1638 · 3 comments · 10 reactions ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#1237 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#1146 · 3 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#988 · 1 comment · 1 reaction ·
All issues in acacode/swagger-typescript-api
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·