OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.81k stars 6.58k forks source link

[Bug] [csharp-netcore] WebClient not supported in Blazor WebAssembly #9660

Open AhmedKhalil777 opened 3 years ago

AhmedKhalil777 commented 3 years ago

Try to support Blazor WASM with generators

System.Net.Requests is not supported on this platform. System.PlatformNotSupportedException System.Net.Requests is not supported on this platform. at System.Net.WebRequest.get_DefaultWebProxy() at RestSharp.RestClient.ConfigureHttp(IRestRequest request) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action2 callback, String httpMethod, Func4 getWebRequest) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action2 callback, Method httpMethod) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action2 callback) at RestSharp.RestClient.ExecuteAsync[CourseDTOPaginatedList](IRestRequest request, Action`2 callback) at RestSharp.RestClient.ExecuteAsync[CourseDTOPaginatedList](IRestRequest request, CancellationToken cancellationToken) --- End of stack trace from previous location ---

devhl-labs commented 3 years ago

Try the library option for httpclient. Post here if it doesnt work. Ive been trying to rewrite the http client but i need my nrt pull request merged first.

AhmedKhalil777 commented 3 years ago

I tried to use it but same error,,

npx @openapitools/openapi-generator-cli generate -i {{url}} -g csharp-netcore -o {{OutPut path}} --additional-properties=library=httpclient

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: System.Net.Requests is not supported on this platform. System.PlatformNotSupportedException: System.Net.Requests is not supported on this platform. at System.Net.WebRequest.get_DefaultWebProxy() at RestSharp.RestClient.ConfigureHttp(IRestRequest request) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action2 callback, String httpMethod, Func4 getWebRequest) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action2 callback, Method httpMethod) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action2 callback) at RestSharp.RestClient.ExecuteAsync[CourseDTOPaginatedList](IRestRequest request, Action`2 callback) at RestSharp.R

devhl-labs commented 3 years ago

I dont think youre passing in the library option for httpclient.