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
  • #5252
Closed
Open
Issue created Feb 09, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] C++ Server (Qt5) does not implement "fromStringValue(const QString &, OAIObject &)"

Created by: redturtlepower

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

Sending a Post request with a json payload (application/json mime type) the generator generates the code

void OAIUserApiRequest::loginUserRequest(){
    qDebug() << "/v1/user/login";
    connect(this, &OAIUserApiRequest::loginUser, handler.data(), &OAIUserApiHandler::loginUser);
    OAIObject body;
    ::OpenAPI::fromStringValue(QString(socket->readAll()), body);
    emit loginUser(body);
}

The function ::OpenAPI::fromStringValue(QString(socket->readAll()), body); is only declared in file helpers-header.mustache but not defined in file helpers-body.mustache.

openapi-generator version

cli: 4.2.3

OpenAPI declaration file content or url

spec.yaml

Command line used for generation

rmdir /s /q .\myapp-api-v1-server java -jar openapi-generator-cli.jar generate -i spec.yaml -g cpp-qt5-qhttpengine-server -o myapp-api-v1-server

Steps to reproduce

Generate the source from the linked spec file. Open the generated file 'OAIUserApiRequest.cpp' at line 53. The code won't link because the function is not defined.

Suggest a fix

Add the following code to file helpers-body.mustache

#include <QJsonParseError>

bool
fromStringValue(const QString &inStr, {{prefix}}Object &value)
{
    QJsonParseError err;
    QJsonDocument::fromJson(inStr.toUtf8(),&err);
    if ( err.error == QJsonParseError::NoError ){
        value.fromJson(inStr);
        return true;
    }
    return false;
}
Assignee
Assign to
Time tracking