OpenAPITools / OpenAPITools/openapi-generator
[cpp-restsdk]How to write the API request in Open API to get response in UTF8 string instead of wide string without using any redundant type conversion
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I want to write an API in OpenAPI so that the generated API function can return JSON response in UTF8 encoding.
but it only returns in string_t wide string.
i check the C++ code definition of the generated function :
The generated function returns wstring by web::http::http_response.extract_string( )
But instead i want to return std:string using web::http::http_response.extract_utf8string();
I know that there is a cpp-restsdk library function conversions::to_utf8string( ) to convert wide string to std::string.
but i want to skip such data conversion function when I can directly get data in actual UTF8 using extract_utf8string.
openapi-generator version 4.3.1
OpenAPI declaration file content or url
/api/v1/user/items:
get:
tags:
- test
summary: Get list.
description: Returns list.
operationId: getList
responses:
'200':
description: Returns JSON array.
content:
application/json:
schema:
type: array
items:
type: string
Command line used for generation
npx @openapitools/openapi-generator-cli generate -i test.yaml -g cpp-restsdk -o %CD%
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
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 cpp-restsdk generator and the generated function that currently calls web::http::http_response.extract_string(). Compare its behavior with extract_utf8string() and the supplied OpenAPI declaration; done means the generated API returns a UTF-8 std::string without a redundant wide-string conversion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100