Skip to content
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

[BUG] [pistache] models don't compile due to calling validate() with no parameters not returning bool #16711

Open
alanb-sony opened this issue Oct 3, 2023 · 2 comments

Comments

@alanb-sony
Copy link

This PR introduced a change to call if (!m_{{name}}.validate()) { but the no-argument validate function throws on errors and returns void, this causes a compiler error:

error: could not convert '((const org::openapitools::Model1*)this)->org::openapitools::Model1::m_Parameters.org::openapitools::Model2::validate()' from 'void' to 'bool'
   47 |     if (!m_Parameters.validate()) {
      |          ~~~~~~~~~~~~~~~~~~~~~^~
      |                               |
      |                               void
openapi/model/Model1.cpp:47:32: error: in argument to unary !
   47 |     if (!m_Parameters.validate()) {
      |                                ^

Found in OpenAPI 7.0.1 with the following command:

npx @openapitools/openapi-generator-cli generate -i api.yml -g cpp-pistache-server -o out
@wing328
Copy link
Member

wing328 commented Nov 21, 2023

thanks for reporting the issue

cc @@ventsyv (the author of the PR)

@sofiane06
Copy link

Hi,

i had the same issue, any news for this please?

error: could not convert ‘((const org::openapitools::server::model::AfEventNotification*)this)->org::openapitools::server::model::AfEventNotification::m_Event.org::openapitools::server::model::AfEvent::validate()’ from ‘void’ to ‘bool’
   48 |     if (!m_Event.validate()) {
      |          ~~~~~~~~~~~~~~~~^~
      |                          |
      |                          void
/home/sofiane/my-workspace/pcf/out1/model/AfEventNotification.cpp:48:27: error: in argument to unary !
   48 |     if (!m_Event.validate()) {
      |                           ^
make[2]: *** [CMakeFiles/api-server.dir/build.make:328: CMakeFiles/api-server.dir/model/AfEventNotification.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/api-server.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

keyjh2 added a commit to keyjh2/openapi-generator that referenced this issue May 6, 2024
…6711)

When components/schema/<object> reference other objects, validate() was
getting called on the referenced objects with no arguments. The return
value was void, but checked as if it was a boolean value.
keyjh2 added a commit to keyjh2/openapi-generator that referenced this issue May 6, 2024
…6711)

When components/schema/<object> reference other objects, validate() was
getting called on the referenced objects with no arguments. The return
value was void, but checked as if it was a boolean value.
wing328 pushed a commit that referenced this issue May 7, 2024
When components/schema/<object> reference other objects, validate() was
getting called on the referenced objects with no arguments. The return
value was void, but checked as if it was a boolean value.
renatomameli pushed a commit to renatomameli/openapi-generator that referenced this issue May 17, 2024
…6711) (OpenAPITools#18586)

When components/schema/<object> reference other objects, validate() was
getting called on the referenced objects with no arguments. The return
value was void, but checked as if it was a boolean value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants