swagger-api / swagger-api/swagger-codegen
[Typescript][Angular] Status Code 204: Accept-Content Header
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Wrong Accept-Content Header for empty response types
Swagger-codegen version
3.0.14
Swagger declaration file content or url
delete:
operationId: deletePartnerByID
tags:
-Partner
summary: Deletes a communication partner
parameters:
- name: deletePartnerByID
in: path
description: ID of partner to delete
required: true
schema:
type: integer
format: int64
responses:
204:
description: OK
400:
description: Invalid ID supplied
content:
application/json: {}
404:
description: Communication partner not found
content:
application/json: {}
Command line used for generation
not needed
Steps to reproduce
Follow the Guideline How to make OpenAPI 3.0 to send an empty Accept-Content Header
https://swagger.io/docs/specification/describing-responses/
(In Our Case for HTTP Status code 204)
Test the generated code.
Watch Request Headers
See Accept-Content Header "application/json"
Related issues/PRs
Suggest a fix/enhancement
Fix this code in modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache
var contentType = this.jsonPreferredMime(contentTypes);
if (contentType) {
if(contentType != 'multipart/form-data') {
request.type(contentType);
}
} else if (!request.header['Content-Type']) {
request.type('application/json');
}
Contributor guide
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.
Research direction
Start in modules/openapi-generator/src/main/resources/Javascript/ApiClient.mustache and inspect how contentTypes are handled for the 204 response in the provided OpenAPI declaration. Generate the TypeScript/Angular client and observe the request headers. Done means the empty 204 response no longer produces an application/json Accept-Content header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100