Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6344
Closed
Open
Issue created May 17, 2020 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[BUG] [Server: C++] [Qt5] Missing headers and wrong status code

Created by: natanlaverde

Bug Report Checklist

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

In class ApiRequest, the helper method writeResponseHeaders is being called in beginning of generated {{nickname}}Response and {{nickname}}Error methods, in such case, some response headers are not present yet (e.g.: Content-Type or Content-Length). When one of the generated methods {{nickname}}Error are called, the HTTP Status Code is wrong, the status code will be always HTTP/1.0 200 OK, even if setStatusCode(QHttpEngine::Socket::NotFound) has been called.

openapi-generator version

5.0.0-SNAPSHOT (master).

OpenAPI declaration file content or url

N/A.

Command line used for generation

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml
-g cpp-qt5-qhttpengine-server
-o /tmp/server/petstore/cpp-qt5-qhttpengine-server

Steps to reproduce

Just generate the code, start server and compare the response headers. When a method that returns json is called, the headers Content-Length and Content-Type are not present. If the generated method set the status to other than HTTP/1.0 200 OK, the code 200 is not incorrectly returned.

Related issues/PRs

N/A.

Suggest a fix

Change helper method writeResponseHeaders implementation to just set the headers, instead of write them, and also rename the method to setSocketResponseHeaders, to maintain the new semantic. The implementation of QHttpEngine::Socket::write or QHttpEngine::Socket::writeJson implementations will call Socket::writeData that writes the Headers and Status Code before write the content if they are not already written. If these methods are not called (e.g.: empty reply), we could set the headers just before close the socket.

Assignee
Assign to
Time tracking