Skip to content

Support for Windows UWP #2241

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
schrooom opened this issue Feb 25, 2016 · 16 comments
Closed

Support for Windows UWP #2241

schrooom opened this issue Feb 25, 2016 · 16 comments

Comments

@schrooom
Copy link
Contributor

Question:

I'd like to use Swagger-Api for a Windows UWP project, but the RestSharp-Library #, which is used for C#-generation (#673), unfortunately has no support for Windows UWP-Apps...

Any way to solve this issue?

@wing328
Copy link
Contributor

wing328 commented Feb 25, 2016

@jerry1621 Thanks for reporting the issue. Have you opened a ticket with RestSharp to see if they've any plan to support Windows UMP apps?

@wing328 wing328 added this to the v2.1.6 milestone Feb 25, 2016
@schrooom
Copy link
Contributor Author

@wing328 There is already an issue since August '15, but unfortunately no updates recently (restsharp/RestSharp#745)

@wing328
Copy link
Contributor

wing328 commented Feb 25, 2016

Seems like the PR for supporting UWP has merged: restsharp/RestSharp#780

@wing328
Copy link
Contributor

wing328 commented Mar 2, 2016

@jerry1621 may I know if it works for you?

@schrooom
Copy link
Contributor Author

schrooom commented Mar 2, 2016

@wing328 Not quite:
While RestSharpUWP supports Windows UWP-devices with x86 and x64 architecture, I'm not able to get it to run on an ARM-powered device and unfortunately all Windows 10 Mobile-devices available are ARM-powered, so I'm able to run it on a Win 10 Desktop but not on Win 10 Mobile, which is the platform I need it for...

@wing328
Copy link
Contributor

wing328 commented Mar 2, 2016

@jerry1621 I would suggest you report your finding to RestSharp team so that they can look into that.

@ndeeH
Copy link

ndeeH commented Mar 11, 2016

Does ARM work now?

@schrooom
Copy link
Contributor Author

@wing328 Unfortunately I got no reaction from RestSharp, but I was able to compile the RestSharp library for ARM-archtiecture and am now doing some further work and testing, because the generated swagger-code still needs some adaptions (mostly because of RestSharp)

@wing328
Copy link
Contributor

wing328 commented Mar 16, 2016

@jerry1621 thanks for doing further work and testing. Can you elaborate on the "adaptions"? Maybe the community can help out on that.

@schrooom
Copy link
Contributor Author

@wing328 Sure, a few examples:

  • In the generated configuation Environment.OSVersion and Assembly.GetExecutingAssembly()... are used, but not available in Windows UWP (which is not critical, because they are used for debug-reports)
  • In the generated ApiClient RestClient.Execute (for the sync http-request, theres an async one too) is used, which is not available on Windows UWP
  • In ApiClient again: in method PrepareRequest() there is this call in a for-loop: request.AddFile(param.Value.Name, param.Value.Writer, [...]; and the param.Value.Writer is a System.Action<System.IO.Stream> as type but byte[] is needed

Those are some things I need to adjust or else I'll get compile-errors...

@wing328 wing328 modified the milestones: v2.2.0, v2.1.6 Mar 16, 2016
@schrooom
Copy link
Contributor Author

Another Update:
After adjusting those things stated above like this

  • new class to replace Environment.OSVersion which provides me with needed information on UWP
  • replaced var response = RestClient.Execute(request); with var response = new object(); in CallApi(...) (which obviously makes CallApi(...) useless, but preventing compile-errors (I am using CallApiAsync(...) instead))
  • wrote a method to convert param.Value.Writer in PrepareRequest(...) from System.Action<System.IO.Stream> to byte[]

All in all those are minor adaptions and now everything works like expected :)

@wing328
Copy link
Contributor

wing328 commented Mar 22, 2016

@jerry1621 thanks for sharing the above with us. Do you mind generating the C# SDK for UMP using https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/test/resources/2_0/petstore.json and then upload it to github to send it directly to me so that we can use reverse engineering to plot back the change to the C# mustache template?

@schrooom
Copy link
Contributor Author

@wing328 Am I getting you right, that you ask me to generate the C# code for that petstore.json and then do those necessary adaptions to send the changed code it to you?

@wing328
Copy link
Contributor

wing328 commented Mar 22, 2016

@jerry1621 yes, or you can provide the one you've already customized to me via my email address (wing328 at yahoo.com) so that I can make the comparison to figure out what changes are needed.

@wing328
Copy link
Contributor

wing328 commented Mar 22, 2016

Submitted #2427 to support UWP

@wing328
Copy link
Contributor

wing328 commented Apr 11, 2016

#2427 merged into master.

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