Skip to content

[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 #7542

Open
@himadree-shekhar

Description

@himadree-shekhar
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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions