OpenAPITools / OpenAPITools/openapi-generator
[csharp-netcore] Deserialization of server response fails when server omits a Content Type header
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When integrating with an API server that doesn't append the proper Content Type header deserialization of the response defaults to Xml so if Json was in fact returned it fails.
openapi-generator version
5.4.0
Command line used for generation
npx @openapitools/openapi-generator-cli generate -i spec.json -g csharp-netcore -o IO.OpenApi.spec --additional-properties=packageName=IO.OpenApi.spec,targetFramework=net5.0
Steps to reproduce
- Run csharp-netcode generator, and library, against any spec that returns json
- Intercept the response and remove the Content Type header before RestSharp tries to decode it. Not easy to do :(
Related issues/PRs
Not that I can find
Suggest a fix/enhancement
PR being submitted
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 with the csharp-netcore generated client and its RestSharp response decoding, using the supplied generation command and spec.json reproduction. Trace how a missing Content Type selects XML instead of JSON. Done means a JSON response without that header deserializes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100