OpenAPITools / OpenAPITools/openapi-generator

[BUG][cpp-restsdk]How to define API with response type "text/html"

Open
#8,989 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

I want to write a API request and generate it in cpp-restsdk.
Content Types are as follows:
Request Content Type: "application/x-www-form-urlencoded"
Response Content Type: "text/html"

openapi-generator version v5.0.1
OpenAPI declaration file content or url
  /api/v1/user/login:
    post:
      tags:
        - login/logout
      summary: Login as a user.
      description: Send login request
      operationId: loginUser
      requestBody:
        description: Send login credentials.
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:               
                username:
                  type: string
                password:
                  type: string                
              required:               
                - username
                - password
              example:                
                username: usr
                password: '123'
      responses:
        '200':          
          content:
            text/html:
              schema:
                type: string
tags:
  - name: login/logout
    description: 'login, logout operations'

After API Code generation, i noticed code block for text/plain were added instead of text/html.
Currently, i am manually editing the parts that are not generated correctly.
So how to fix this problem.

Generated Code:
localVarResponseHttpContentType = utility::conversions::to_string_t("text/plain");

else if(localVarResponseHttpContentType == utility::conversions::to_string_t(**"text/plain"**))
{
    localVarResult = localVarResponse;
}        
Generation Details
npx openapi-generator-cli generate -g cpp-restsdk -i test.yaml -o ./cpp
Steps to reproduce
Related issues/PRs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied OpenAPI declaration and run the shown openapi-generator CLI command for the cpp-restsdk generator. Inspect the generated response-content-type handling, where text/html is emitted as text/plain, and verify that the generated client preserves the declared text/html response type.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.