OpenAPITools / OpenAPITools/openapi-generator

[BUG][cpp-restsdk]How to define login API to return cookie from response header for cpp-restsdk generator

Open
#8,990 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C++ 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 for login request.
If the login request is successful then it API should return the cookie from the response header.

openapi-generator version 5.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':
          description: returns cookie from header.          
          content:
            text/html:
              schema:
                type: string
tags:
  - name: login/logout
    description: 'login, logout operations'

Generated Code:
The generated API function, it only returns the HTTP body instead of the extracting cookie from the header:
return localVarResponse.extract_string();
So, How can we get the cookie.

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 test.yaml and run the reported npx openapi-generator-cli command for the cpp-restsdk generator. Inspect the generated loginUser API function, especially the return localVarResponse.extract_string() call, to determine how response headers are exposed. Done means reproducing the behavior and establishing a documented or testable way to obtain the login cookie.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.