Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][cpp-qt5-client] Header params in api-body operations use param name instead of value #2726

Closed
5 of 6 tasks
aspaseltiner opened this issue Apr 23, 2019 · 2 comments
Closed
5 of 6 tasks

Comments

@aspaseltiner
Copy link
Contributor

aspaseltiner commented Apr 23, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Header parameters don't get included in requests made by cpp-qt5-client because of a mistake in the Mustache template file for the API client:

{{#headerParams}}
if ({{paramName}} != nullptr) {
input.headers.insert("{{baseName}}", "{{paramName}}");
}
{{/headerParams}}

input.headers.insert("{{baseName}}", "{{paramName}}"); should be input.headers.insert("{{baseName}}", {{paramName}});.

openapi-generator version

Docker Hub, latest

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  description: Test
  version: 0.0.1
  title: Test
tags:
  - name: test
    description: test
paths:
  /test:
    get:
      tags:
        - test
      summary: test
      operationId: test
      parameters:
        - in: header
          name: TestHeader
          schema:
            type: string
      responses:
        "200":
          description: successful operation
Command line used for generation

docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:latest generate -i /local/api.yaml -g cpp-qt5-client -o /local/out

Steps to reproduce

Generate a C++ QT5 client using the above docker run command.

${PWD}/out/client/OAITestAPI.cpp will contain:

void
OAITestApi::test(const QString& test_header) {
    QString fullPath;
    fullPath.append(this->host).append(this->basePath).append("/test");
    
    OAIHttpRequestWorker *worker = new OAIHttpRequestWorker();
    OAIHttpRequestInput input(fullPath, "GET");

    if (test_header != nullptr) {
        input.headers.insert("TestHeader", "test_header");
    }

    foreach(QString key, this->defaultHeaders.keys()) {
        input.headers.insert(key, this->defaultHeaders.value(key));
    }

    connect(worker,
            &OAIHttpRequestWorker::on_execution_finished,
            this,
            &OAITestApi::testCallback);

    worker->execute(&input);
}

Expected output:

    if (test_header != nullptr) {
        input.headers.insert("TestHeader", test_header);
    }
Related issues/PRs
Suggest a fix
@auto-labeler
Copy link

auto-labeler bot commented Apr 23, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@aspaseltiner
Copy link
Contributor Author

Added PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants