swagger-api / swagger-api/swagger-codegen
[JAVA] Content-Type is overwritten
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
The Content-Type is always overwritten even if it has been supplied.
If a header parameter is described as follow
parameters:
content-type:
name: Content-Type
in: header
description: Content type
type: string
required: true
The client should be able to specify the content type of the request but this gets overwritten by the Java API. See https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache#L95
Maybe we should check if a Content-Type has already been supplied before overwriting assuming that if a client is supplying a Content-Type he knows what he is doing.
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
Inspect modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/api.mustache around line 95, where the Content-Type is overwritten. Reproduce the case with a supplied Content-Type header and confirm that the generated Java client preserves it; done means generated requests retain the caller-provided value instead of replacing it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100