OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.3k stars 6.44k forks source link

[BUG][C][cpp-restsdk] Missing Set.h when trying to generate from Twitter OpenAPI JSON #9969

Open HunterZ opened 3 years ago

HunterZ commented 3 years ago

Bug Report Checklist

Description

When trying to build C or cpprestsdk APIs generated from Twitter's official OpenAPI JSON, I get missing Set.h and AnyType.h header errors.

openapi-generator version

Latest stable and master offered by official online generators as of time of this bug report.

OpenAPI declaration file content or url

https://api.twitter.com/labs/2/openapi.json as advertised by https://developer.twitter.com/en/docs/labs

Generation Details
Steps to reproduce
Related issues/PRs
Suggest a fix
HunterZ commented 3 years ago

Someone suggested that maybe I was using the wrong Twitter spec, but I get the same errors from this one: api.twitter.com/2/openapi.json

IARI commented 3 years ago

I suggest to put a [C] in the Issue title.

wing328 commented 3 years ago

Looks like the cpp-restsdk client generator doesn't support set at the moment.

We welcome contributions or sponsorships for a fix.

dratchkov commented 2 years ago

Just hit this issue myself. This change from std::vector needs to be undone completely.

  1. Set.h and Set are not standard. Was the intent to use and std::set?
  2. std::set is an ordered container, which comes - there is a lot of overhead to populating one as all data needs to be inserted into a balanced tree. Maybe use std::unordered_set?
  3. std::unordered_set is not overhead free either.
  4. std::set and std::unordered_set will change the order of data form the original json. This effect is undesirable.

Please revert to using std::vector

mlebihan commented 4 months ago

This fix (in need of further testings) seems to allow generation:
https://github.com/OpenAPITools/openapi-generator/compare/master...mlebihan:openapi-generator:cpp-restsdk_Missing_Set_h_9969

@dratchkov I did also a change in cpp-pistache-server to consider the set as a std::set and not a std::vector anymore.