-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[CPPREST][CPP] Several Compilation Errors, setTags method missing #5862
Comments
I have posted the Azure IOTHub SDK with the issues here: |
@solvingj I would suggest you to try the latest master to see if you can still repeat the issue as there're 9 PRs for CppRest since last stable release (which is used by the Swagger Editors) |
I saw that but I wasn't sure which branch/version the swagger editors were built from. Furthermore, I only ever generated from the web interface. I'm not really an expert developer, so I don't know that I'm capable of compiling and building the generator and running it locally (or at least, not without spending a day on it and asking someone for help). When do you think the new generator code will be live on online editor? |
@solvingj what about using the pre-built Swagger Codegen CLI Docker image: https:/swagger-api/swagger-codegen#public-pre-built-docker-images?
We hope to do it by the end of July (it was already postponed from May 31st) |
I actually did use the docker pre-built Swagger Codegen CLI image last night, and was able to generate. It still has the same issues. Will try to get post specific errors soon. Here is the branch with the latest: |
I have the same issue, I tried to generate the Swagger spec of the Azure IoT Hub and it generates a lot of errors where it tries to call
It seems to me like it's generating the wrong type there. |
Yup, I think likely that's the case so we'll need to remove the code copied from the QT5 templates. The @solvingj @klemens-morgenstern May I know if you've time to contribute a PR to clean up the auto-generated code for CPPREST generator? |
I'm a not experienced enough to be helpful. I barely know any C++, and don't understand how the code-generation in swagger codegen works really. It seems like this will require someone who understands both . |
I digged into this issue a little bit deeper and it turns out I was wrong about copying the code from QT5 templates. The issue was due to missing "setter" for properties that are "array": Using the Petstore store example, the Pet model has the property My question is what would the setter look like so that I can add it back to the model template for cpprest? |
…e as specified in contract (#5791) * fixed map to use value instead of mapentry while doing fromJson. * cpprest models now use inheritance properly instead of always extending from ModelBase * cpprest models now use inheritance properly instead of always extending from ModelBase * removed a sysout used for debugging * toJson() and fromJson() now leverages parent class's corresponding methods * virtual is not needed as override essentially does the same thing. * added docstring for getModelByName * corrected the javadoc * fixed @param issue in javadoc * fixed @param uncapitalized P in param in javadoc
@stkrwork already tested cpprest for us, check my comments above, looks like still broken are: |
Can you share a bit more details? Did you get compilation errors? If yes, please provide them. The steps you provided previously are very helpful
|
FYI, I have been working on this for the past hour. Will continue. |
Here are some examples of the errors which still exist
|
I might look into this today |
The template is only recognizing the isListContainer and isPrimitiveType when generating, and a default generation template. As tags in this case is a map, the isMapContainer needs to be checked. I am implementing that change currently, which means it should work then. The other complexTypes are handled ok with the default, I think. The petstore example models don't have a map datatype, so therefore this error could never be seen in the samples. The question is, how do you want to represent the map in the json? In form of this? Or would another format be better? |
Right, the cpprest petstore samples (based on petstore.yaml) only covers the basic. We've created petstore-with-fake-endpoints-models-for-testing.yaml to cover a lot more edge cases such as map datatype and map of map as well. |
For a first step, I am implementing a way for using maps and not maps of maps, as maps of maps will require refactoring of the modelbase as well, as everything needs to be moved into new functions for lists and maps. |
Yup, that's totally fine (I'm not saying you need to fix all the edge cases covered by petstore-with-fake-endpoints-models-for-testing.yaml) |
Can you look through the template @wing328, because according to my changes, it should generate the map components correctly, but when using it with the spec provided in this issue, it still generates it the wrong way, so I am a little confused. |
Gave it a try, now up to 82 errors currently. @stkrwork do you get the same number of errors? Here's what mine generated, maybe @stkrwork can double check that I did get the latest changes from #5884. https:/solvingJ/azure-iothub-sdk-cpprest/tree/Swagger_codegen_2_2_3-snapshot_6_20 Steps to reproduce on windows 10:
I've put my build log in the following file which includes every source file that has an error, and tells what line number it is. Sorry, error logs are kinda hard to read: |
I'll review it tomorrow. |
It now generates and compiles your spec correctly. I used Visual Studio 17 for it. I did not use conan, but it should not make a major difference. There were some issues with Syntax and not escaping some signs correctly. but that should be fixed now. |
#5893 is pr |
* - Added Restbed Generator * - Added Json processing functions to model - Removed unnused code from restbed codegen class - Added response header processing to api template * Changed it to respect alphabetical order * Made the string joining java 7 compatible * Added samples * First step in fixing the cpp rest template regenerated new samples TODO: Fix the other functions * Updated samples * Added isMapContainer check * Fixed item selection in json object for MapContainer * - Fixed Syntax error in C++ - Fixed Syntax error in Mustache, that escaped characters
#5893 merged into master. Please give it a try. |
@wing328 FYI I'm trying to get setup to build this project from source today. I'm using windows/docker for windows and a novice with docker, so i'm just working through adjusting the scripts to work on my machine. |
If you're using Windows, you can also build the project locally by installing Maven (mvn command) |
@wing328 |
@stkrwork
|
I let it run through again, and it looks fine to me. there seems to be no build errors when i compile it. |
Is there any difference with my ModelBase.cpp (visible here); If you look at my errors, do you have any idea what would cause them?
|
utility::string_t is nothing else but a std::string. I ran your code from your repo as well, and there were no errors for me when i used it with Visual Studio 15. I included cpprestsdk and boost with the NuGet package manager in this case. |
What do you use when building it? |
Msbuild "Visual Studio 15 2017 Win64" |
Ok. Thats quite similar to my setup right now. I used the versions from your conan file as well for cpprestsdk and boost, and it still compiled fine for me. I again used the Nuget Package Manager. |
I'm on Boost 1.5.9. I'll try upgrading when I get home. I don't know if any of the following is relevant, but here's what I found: The following weird statements print in the msbuild log, but don't seem to be errors. I googled, which indicated it might be related to boost.
The two main issues are lines 292 and 297, which I can easily fix by replacing The other two errors are about throw statements, which I don't know how to fix because I don't understand this "U()" thing. However, I can easily comment those out for now. I also have a warning:
Regarding your comment about strings, I wanted to clarify something. The stack overflow post had the following exchange:
That seems similar to your comment, and someone replied:
If it was something like this, it doesn't really explain why it works for you with cmake -G "Visual Studio 14 2015 Win64". Also, I don't know why, but when I run that cmake command, it says:
|
So, found I had uninstalled VS 2015.. guess that was obvious. I re-installed, and sure enough the library builds fine under 2015. Thank you so much! I'm curious what this means for support on VS2017. Should the template be modified so that it works under 2017? |
i built it with visual studio 2017 as well, directly in the IDE, and it built fine there as well. |
Must have to do with the versions of CPPRest and/or Conan I'm using. Thanks for helping me figure this out, and fixing the code. |
No problem |
Adding this to my todo list. FYI, we've still not been able to test with the latest CPPRest (It's surprisingly hard to build). Will soon though. |
@solvingj thanks. I'll close this issue, which has been resolved, and open a new one for tracking instead. |
Description
There are several methods which are causing compilation errors.
fromJson
fromMultipart
setTags
While I am able to find fromJson and fromMultipart, I cannot find the method setTags method anywhere. Interestingly, I generated Petstore and Petstore on Heroku samples and this method was not referenced anywhere in that code. Perhaps those specs don't have custom tags and my spec does.
Swagger-codegen version
http://editor.swagger.io
http://editor2.swagger.io
Swagger declaration file content or url
Here is the JSON Swagger spec:
https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-iothub/2017-01-19/swagger/iothub.json
Command line used for generation
http://editor.swagger.io
http://editor2.swagger.io
Both produce this method setTags()
Steps to reproduce
This method does not exist anywhere in any version of the the Microsoft CPPREST library:
https:/Microsoft/cpprestsdk
Nor does it exist in the generated sources.
Related issues
I could find no previous github issue referencing the setTags method.
Suggest a Fix
I noticed that the QT5 sample for petstore also references the setTags method. In researching, I saw that the CPPREST generator was probably based off the QT5 generator to some extent. It seems possible that the generation of setTags() was copied from the QT5 generator but without the code that generates an implementation of the method. Meanwhile, perhaps none of the sample specs used for testing happen to feature custom tags, so it never got generated during testing and never discovered. All very speculative, I'm really not sure.
The text was updated successfully, but these errors were encountered: