Skip to content
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

Generated C# code uses RestSharp 105.1.0 which has a bug in its proxy imlementation #7498

Closed
ChrisKeut opened this issue Sep 24, 2020 · 13 comments

Comments

@ChrisKeut
Copy link

The current version of openapi-generator-cli (4.3.1) uses RestSharp 105.1.0 for its C# code generation. RestSharp 105.1.0 has a known bug in its proxy-implementation. A later version (106.3) has fixed this bug. Could you please update this dependency. If I manually change the RestSharp.dll to 106.3.1 I get a compile error in the generated code.

@wing328
Copy link
Member

wing328 commented Sep 24, 2020

@ChrisKeut can you please check the latest master, which should have the C# dependencies updated to newer versions?

@ChrisKeut
Copy link
Author

@wing328 sorry I'm new to github. I downloaded openapi-generator-cli-5.0.0-beta2.jar but in packages.config 105.1.0 is listed:

Have I downloaded the wrong jar? How i get the latest master?
Thanks

@wing328
Copy link
Member

wing328 commented Sep 24, 2020

Search for "SNAPSHOT" in the projecjt's readme and you will find a link to a page listing all the SNAPSHOT version. Then scroll down to find the latest JAR (snapshot version of the latest master)

@ChrisKeut
Copy link
Author

OK, done (openapi-generator-cli-5.0.0-20200924.091403-684.jar). But also 105.1.0 in packages.config

@wing328
Copy link
Member

wing328 commented Sep 24, 2020

Can you please try csharp-netcore generator? I think you tried csharp client generator.

@ChrisKeut
Copy link
Author

Yes I have used "csharp" because I have a .Net 4.52 client application. I can't use .Net Core. Any ideas? Thanks!

@wing328
Copy link
Member

wing328 commented Sep 24, 2020

What about .NET standard (the default of csharp-netcore) which is compatible with .NET 4.x?

@ChrisKeut
Copy link
Author

OK, let me install Visual Studio 19 to check it.

@wing328
Copy link
Member

wing328 commented Sep 24, 2020

@ChrisKeut I assume it resolves the issue for you, right?

@ChrisKeut
Copy link
Author

@wing328 No, not really

  1. In the generated code I get: The type or namespace name 'HTTPSigningConfiguration' could not be found in Configuration.cs and IReadableConfiguration.cs (have commented it out!)
  2. When I add the generated Project to my solution and make a reference to the generated project in my .NET 4.5.2 Windows Forms project I get: 'Org.OpenAPITools.csproj' targets 'netstandard2.0'. It cannot be referenced by a project that targets '.NETFramework, Version=4.5.2'

@ChrisKeut ChrisKeut reopened this Sep 24, 2020
@wing328
Copy link
Member

wing328 commented Sep 24, 2020

For 1, I've filed #7504 to fix it.

For 2, you may want to use the following option to pick a different .net standard version:

	targetFramework
	    The target .NET framework version. (Default: netstandard2.0)
	        netstandard1.3 - .NET Standard 1.3 compatible
	        netstandard1.4 - .NET Standard 1.4 compatible
	        netstandard1.5 - .NET Standard 1.5 compatible
	        netstandard1.6 - .NET Standard 1.6 compatible
	        netstandard2.0 - .NET Standard 2.0 compatible
	        netstandard2.1 - .NET Standard 2.1 compatible
	        netcoreapp2.0 - .NET Core 2.0 compatible
	        netcoreapp2.1 - .NET Core 2.1 compatible
	        netcoreapp3.0 - .NET Core 3.0 compatible
	        netcoreapp3.1 - .NET Core 3.1 compatible

ref: https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support

@ChrisKeut
Copy link
Author

Thank you wing328! Ended up to port my Windows Froms application to .Net Core Windows Forms. Now the references to the generated project works. Currently i'm struggling with the new API.

@ChrisKeut
Copy link
Author

ChrisKeut commented Sep 25, 2020

@wing328 Finally I found out that I didn't had a problem with openapi-codegen or the used RestSharp version. The problem was that the .NET Framework, even if you set Proxy.BypassProxyOnLocal = false, don't uses the proxy on a localhost endpoint. I solved the problem by adding a dot after localhost (like: http://localhost.:8080/...) I needed to set the proxy to test my api with Burp Suite. Still it would be good to update the dependencies for csharp also.
Thank you very much!

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

2 participants