Skip to content

[QT5CPP] Code generator does not handle the additionalproperties section of the yaml for qt5cpp #6841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
etherealjoy opened this issue Oct 28, 2017 · 6 comments · Fixed by #6886

Comments

@etherealjoy
Copy link
Contributor

etherealjoy commented Oct 28, 2017

Code generator does not handle the additionalproperties section of the yaml for qt5cpp

Description

Whenever the yaml have additionalProperties the generated code is missing handling for the QMap caused by the arbitrary name of the property.

when the additionalProperties is referencing an array the generated code is also missing handling the QList from the additional property which may then host a normal property.

Swagger-codegen version

The problem is reproducible in v2.2.3 and v3.0.0
It is not a regression.

Swagger declaration file content or url

https://docs.docker.com/engine/api/v1.31/swagger.yaml

Command line used for generation

java -jar /home/dev/swagger-codegen/swagger-codegen-cli-3.0.0-20171009.075709-6.jar generate -i /mnt/YoctoDisk/genivi/genivi-dev-platform/meta-userapp/recipes-dockerctrl/dockerctrl/sources/dockerctrl-qtapp/docker-v132-subset.yaml -o /mnt/YoctoDisk/genivi/genivi-dev-platform/meta-userapp/recipes-dockerctrl/dockerctrl/sources/dockerctrl-qtapp/gen-qt1 -l qt5cpp

java -jar /home/dev/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i /mnt/YoctoDisk/genivi/genivi-dev-platform/meta-userapp/recipes-dockerctrl/dockerctrl/sources/dockerctrl-qtapp/docker-v132-subset.yaml -o /mnt/YoctoDisk/genivi/genivi-dev-platform/meta-userapp/recipes-dockerctrl/dockerctrl/sources/dockerctrl-qtapp/gen-qt1 -l qt5cpp

Steps to reproduce

Have the yaml code referencing additional properties pointing to an array type, and then the code generation is missing some steps to deserialize the json data.

Related issues/PRs

I have not seen this issue yet in the known issues

Suggest a fix/enhancement
  • fix handling of QMap for the additionalproperties arbitrary section.
  • provide means to access the QMap for both key and json value
  • when the QMap has an array as JSon value there has to be a way to access that
@etherealjoy etherealjoy changed the title [QT5CPP] Code generator does not handle the **additionalproperties** section of the yaml for qt5cpp [QT5CPP] Code generator does not handle the additionalproperties section of the yaml for qt5cpp Oct 28, 2017
@wing328
Copy link
Contributor

wing328 commented Nov 1, 2017

@etherealjoy thanks for reporting the issue. Can you please try the below?

@wing328 wing328 added this to the v2.3.0 milestone Nov 1, 2017
@etherealjoy
Copy link
Contributor Author

etherealjoy commented Nov 3, 2017

@wing328
I tried the v2.3.0, apparently the fix was for cpprest. This issue is present in qt5cpp.
So the issue still exists. I fixed manually by hand some models. but since there are many models I cannot fix each and everyone. :(

I will try to modify the generator, to see if it works, using the cpprest changes.

@etherealjoy
Copy link
Contributor Author

etherealjoy commented Nov 4, 2017

@wing328 OK, I fixed the mustache template for generating the additional properties.
Now I could suggest some hints to changes the mustache file.

https://gist.github.com/etherealjoy/26cb7627a53b3cd18d8440232786d89a

Now I discovered another bug. I will create another issue for it.

@wing328
Copy link
Contributor

wing328 commented Nov 4, 2017

I fixed the mustache template for generating the additional properties.

Please file a PR with the fix when you've time.

Now I discovered another bug. I will create another issue for it.

Yes, please and have a nice weekend.

etherealjoy added a commit to etherealjoy/swagger-codegen that referenced this issue Nov 4, 2017
…is generated.

The issue swagger-api#6884 is still present and requires fixing outside of mustache file as well.
wing328 pushed a commit that referenced this issue Nov 12, 2017
…d. (#6886)

The issue #6884 is still present and requires fixing outside of mustache file as well.
jimschubert added a commit to jimschubert/swagger-codegen that referenced this issue Nov 14, 2017
* master: (101 commits)
  [Swift4] Allow for custom dateformatter to be used (swagger-api#6672)
  [haskell-http-client] fix bug when generating models-only (swagger-api#6931)
  fix typo: crediential => credential
  minor typo fix
  [csharp] fix enum serialization of first value (swagger-api#6873)
  [PHP] Improve docs and README (swagger-api#6935)
  Binary mode for file deserialization in python (swagger-api#6936)
  add python tornado test to travis
  [Python/tornado] add integration tests and fix bugs (swagger-api#6925)
  Fix PHP passes response body to ApiException (swagger-api#6923)
  [TypeScript][Node] Resolve TS2532 error (swagger-api#6932)
  skip "all" shell script
  minor formatting change
  Fixes Issue swagger-api#6841, Map for accessing additionalProperties is generated. (swagger-api#6886)
  add tsloughter as owner erlang
  WIP: initial commit for Erlang client generator (swagger-api#6502)
  add back php client test
  Switch Travis image from MacOS to Linux (swagger-api#6937)
  add link to ebook
  [Scala] Default case class Option types to None for non-required fields (swagger-api#6790)
  ...
@wing328 wing328 closed this as completed Dec 15, 2017
@wing328
Copy link
Contributor

wing328 commented Dec 16, 2017

@etherealjoy when you've time, I wonder if you can contact me via my email address on my Github profile. Thanks.

@wing328
Copy link
Contributor

wing328 commented Feb 21, 2018

@etherealjoy sorry, please send me another email again when you've time as I've lost your previous email.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants