OpenAPITools / OpenAPITools/openapi-generator
[Bug][cpp-restsdk]Call extract_string() will not get correct string when media type is not "application/json"
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- [ ✓ ] Have you provided a full/minimal spec to reproduce the issue?
- [ ✓ ] Have you validated the input using an OpenAPI validator ([example](https://apidevtools.org/swagger-parser/online/))?
- [ ✓ ] Have you tested with the latest master to confirm the issue still exists?
- [ ✓ ] Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
1.CPP-RESTSDK will extract string with default input parm : ignore_content_type = false https://github.com/microsoft/cpprestsdk/blob/master/Release/include/cpprest/http_msg.h#L613-L619
2.When a json has a customed content type , the content type validation will cause the extract string get incorrect value.
3.Additional,As https://en.wikipedia.org/wiki/Media_type says , there is common content type like "application/json" and also other customed content type , which only need to follow the standards.
Why this will cause incorrect value , jump to the code ,we see :
openapi-generator version
master , 5.4.0
Suggest a fix
For 2. ,suggest hard code the extract_string(true)
return localVarResponse.extract_string(true);
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 at modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/api-source.mustache around line 309 and review how extract_string() handles non-application/json media types. Update the generated call as suggested, then verify that generated C++ REST SDK clients extract the expected string for custom media types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100