openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

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

Open HunterZ opened this issue 4 years ago • 5 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
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 avatar Jul 18 '21 21:07 HunterZ

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

HunterZ avatar Jul 18 '21 21:07 HunterZ

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

IARI avatar Jul 25 '21 21:07 IARI

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

We welcome contributions or sponsorships for a fix.

wing328 avatar Aug 01 '21 02:08 wing328

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

dratchkov avatar Oct 16 '21 14:10 dratchkov

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.

mlebihan avatar May 07 '24 05:05 mlebihan