-
Notifications
You must be signed in to change notification settings - Fork 147
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
Compile Errors in project #19
Comments
@bharathreddy-97 which version of Xcode are you using? This project requires Swift 3.1 (Xcode 8.3) |
oh ok I will update Xcode(currently using 8.2.1) and check it. Thank you for the fast response |
No problem. Let me know if you have any other trouble, or if the generated API for your spec has any problems |
I updated the xcode and tried. I generated xcodeproj but where should i run the command. I tried it in terminal(where .xcodeproj is generated) but i am getting SwagGen: command not found. Am i missing something? I tried running Swaggen project. I was getting "Must provide a valid spec" in console. Where can i pass these from? I am new so please bear with me |
Run these two commands in the root of the repo
For the second command append your spec and destination arguments Let me know if you have any more trouble |
Thank you. I finally generated files but in other way to your suggestion. I opened .xcodeproj and in the main.swift i added paths in the command at the bottom. Thank you for replying. One last thing how can i add prefix to model names like in Swagger we use "--model-name-prefix prefixName". |
I added source folder to my project(added JSONUtilities and Alamofire to my project) but was getting some compile error in one of the classes Requests folder. Below is the error Use of undeclared type 'UNKNOWN' json corresponding to that api "/v1/types": {
|
If you're using a the xcode project to run the command, it's best to specify the paths as scheme arguments by editing the scheme. In which generated file is the UNKNOWN? |
There's no inbuilt model prefixing, but you can change the |
Actually, thinking about it some more, just changing the model name as above wouldn't work, as all the references to it would be broken. |
I got Unknown type in one of the generated files in Request folder. The exact line is extension API {
|
I actually had another major issue. For one of the Swagger json when i generated the files some of the filesnames are same which is throwing compile time error in xcode. How are you generating those files(naming) in the Requests folder? |
The request names are generated using the operationId of each operation. If non exists one is generated using the method type and path (can be ugly though). The latest 0.5.2 release may also fix something |
Then this is the problem. In my Swagger json there are more than one operation with same operationId. What can i do in that case? Can i make use of description, summary params? Sorry I cannot give you the Swagger spec(organisation policy) |
Oh ok, that's not really to spec then, and SwagGen doesn't support it. Quoting the Swagger Spec:
|
If you can't change the operationId's for some reason, you can change the code here to always automatically generate an operationId https://github.com/yonaskolb/SwagGen/blob/master/Sources/SwagGenKit/CodeFormatter.swift#L84 |
I have asked my server guys to use seperate operationIds for each operation. There was a request where i have to pass a string in body but it is a enhancement right? What about that first Issue about that Type? Just curious what is that {{ }} syntax you used for code generating? Is that syntax available in swift or what is it? I searched in the net but could not find much on it. I could only find other code-generators using it. Does it have a name or where can i learn it? |
Issue #21 is outstanding. I may be able to get around to it soon. Feel free to also create any pull requests though. Are you able to post an obfuscated version of your request with a string body? The UNKNOWN type issue seems to be a bug where arrays of anonymous enums are not supported as return types. In this case it can't find what the name of the enum should be, which even a human would have trouble figuring out. I guess I'll just called it In terms of the {{ }}, see the readme. It explains that that is the https://github.com/kylef/Stencil format |
I tried sending String in the body but I got a error saying outer most body type should be JSON type or something like that. |
Can you please share a version of your full operation spec where you send a string body. You can change the names if you like |
Just check this one. I have trimmed the json. I actually had another error but was able to solve that error by changing Request template. There was empty Body struct creating which was not conforming JSONValueEncodable and because of it body?.encode() was throwing error. I fixed it by conforming it and implementing encode in that body struct.
|
@bharathreddy-97, just so you know the |
I was using Swagger codegen until recently. I had encountered error. I tried to generate files from SwagGen. I downloaded the repo project and created xcodeproj using this command in terminal "swift package generate-xcodeproj".
I opened the project but i had some compile time errors in Sources/SwagGenKit/Utilities.swift
"/Users/next/Downloads/SwagGen-master/Sources/SwagGenKit/Utilities.swift:11:32: Same-type requirement makes generic parameter 'Key' non-generic"
Did i do something wrong in the installation process? I created a script file in folder and tried to run the script file but i got "Swag: command not found". Please guide me
The text was updated successfully, but these errors were encountered: