-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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][C++][Pistache-server] Array of string : The generator omits the "setter" and xxxIsSet() #2700
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Ok I found the explanation inside the mustache file :
EDIT: Deleted patch file 'cause it was incomplete. See below the other comment @etherealjoy let me know if I'm wrong (or not) |
Array of strings is a container, so this is correct, there is a regression some where else |
Yes you are right but I misspoke : I meant I wonder why the setter should not be generated when the type is a Container. No setter for an array of strings for example ? So, how should we set it without any setter :huh ? Take care, my previous patch was not correct ! More over, I had a look inside the cpp-qt5-qhttpengine-server corresponding model file and I found no constraint like that. Please, have a look to the new patch and let me know if I missed something. It may occurs 😸
|
For the container it not a problem because it is not a const for that purpose. To be able to get the map or array and then you can append or clear. This is how it is in pistache. |
In the Qt5 server the return is a const. so you cannot append or clear anything.
The only way to set it is to use the setter
In Pistache there is no const in the getter and also no setter because not needed |
I understand but that means the m_xxxIsSet member variable will never be true and thus, the to_json will never deserialize this container (it checks xxxIsSet() to do the job)
Something is still blocking (in my brain) ^^ |
We can change to the |
I don't know if it would be the best solution but at least, something have to be modified cause, currently, the to_json method does not work with a container (see my comment above). I understand why the current return is a reference (not const). It gives the opportunity to add, delete, modify some items inside the container without destroying all the current container to set another copy of another instance. That make sens but at least, again, we need to modify something to make the to_json working. EDIT: If we want to let the code as it exist today, what about adding a method as below :
To mark the container Xxxx set and thus, make the to_json method work. This would be the opposite of the already coded method :
I think we also should do some modifications in the model getter (not container). I notice that all getters returned a copy of internal objects... ouchh, the performances are so low regarding a const ref return. I will open another ticket for that. |
I think there is a ticket for this, #1175 |
You know all the opened bug issues ? :D
My intention would be to defined it as below :
This will avoid a temporary object construction. When we are able to write some kind of code :
The reference return is mandatory instead of a copy, in my opinion. |
Getting a ref is not always good, because sometimes the object being held gets descoped somewhere else especially for server side when handling multiple requests on different threads.
For this issue we could do the isSet and const ref param in the setter and avoid returning ref to object member |
Bug Report Checklist
Description
The generator does generates lots of usual code but the setter of the member variable (std::vectorstd::string type) is not here.
The getter is also "strange" or at least unsual because it returns the reference on the member without the qualification const, so that it may be modified.
Last, the usual function ClassName::memberNameIsSet() is not generated too.
On the opposite, lots of code is well generated and running, for example toJson and fromJson methods (except the the set of the bool variable m_xxxIsSet = true
unsetXXXX() is also well generated.
openapi-generator version
Current master 4.0.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
Generate :
Compile :
Steps to reproduce
Generate & compile
Related issues/PRs
N/A
Suggest a fix
EDIT: See below in the comment please
The text was updated successfully, but these errors were encountered: