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
  • #11621
Closed
Open
Issue created Feb 16, 2022 by Administrator@rootContributor6 of 7 checklist items completed6/7 checklist items

[BUG] qt-client missing qHash and operator== for schemes with unique models

Created by: Thaulino

Bug Report Checklist

  • How to reproduce ?
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
First of all: Props to all contributors and thanks for the openapi-generator 😃
Description

The generated code produced by the qt-client generator does not compile, if a scheme is included which includes lists of unique items.

openapi-generator version
  • 5.2.0
  • openapi-generator-cli-6.0.0-20211025.061654-22.jar (newest ?)
OpenAPI declaration file content or url

https://app.swaggerhub.com/apis/Pepperl-Fuchs/Sensorik4.0/1.0.0#/common.identification.identification_1

alternative: www.pepperl-fuchs.com/openapi -> click on Pepperl+Fuchs Sensorik4.0® will be redirected

The issue is rooted in the SCHEMAS:

  • common.identification.identification
  • common.identification.identification_1

which include sets of unique objects.

Generation Details

Unsure what i should enter here: i am using vcpkg, c++, CMake and qt,
platform: win10
ide: vs2019

Steps to reproduce
  1. Install dependencies

If you are using vcpkg: My vcpkg.json

{
	"name": "openapisensorik40",
	"version-string" : "1.0",
	"description": "project to implement the openapisensorik40",
	"dependencies": [
		"qt5-base",
		"openssl"
	]
}
  1. Download the mentioned oai specification
  2. Run open-api-generator
  3. Run Cmake to configure and build the library

An error is thrown, something like:

qHash: none of the 37 overloads could convert argument types for OAICommon_identification_identification_1 OAICommon_identification_identification

Related issues/PRs

None?

Suggest a fix

From my point of view the issue is cause in some missing definition in order to make qhash(needed by QSet ) with a custom class work:
Refer: https://doc.qt.io/qt-5/qhash.html#qhash

I fixxed the issue by adding an operator== and a hash function to the classes.

Wihtin OAICommon_identification_identification_1.h: Add following function/ properties: to OAICommon_identification_identification_1 Within class definition (public)

bool operator==(const OAICommon_identification_identification_1& other) const {  
    return (this->asJsonObject() == other.asJsonObject());  
}  

End of file prior #endif

inline uint qHash(const OpenAPI::OAICommon_identification_identification_1& obj, uint seed = 0)
{
    return qHash(obj.asJsonObject(), seed);
}

Wihtin OAICommon_identification_identification_2.h: Add following function/ properties: to OAICommon_identification_identification_2 Within class definition (public)

bool operator==(const OAICommon_identification_identification_2& other) const {  
    return (this->asJsonObject() == other.asJsonObject());  
}  

End of file prior #endif

inline uint qHash(const OpenAPI::OAICommon_identification_identification_2& obj, uint seed = 0)
{
    return qHash(obj.asJsonObject(), seed);
}

Well i think it is possible to add this to the corresponding mustache file, but right now i am pretty unsure where to start and if it is enough or need some additional coding.

Can someone advice ?

Assignee
Assign to
Time tracking