swagger-api / swagger-codegen

swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
http://swagger.io
Apache License 2.0
16.9k stars 6.03k forks source link

Dot NET Core 2.0 client #7887

Open MCerk opened 6 years ago

MCerk commented 6 years ago

Hello,

I have found a solution, how to generate .NET CORE 2.0 compatible client code (csharp). The RestSharp nuget should be pointed to version 6.2.1 and there should be only one line of code changed in file:

swagger-codegen/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache

Line no.: 156

From:

request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);

to:

request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentLength, param.Value.ContentType);

Cheers,

Matej

AuroraBrignola commented 6 years ago

Hi, I am just about to try this, but is there any chance you were able to generate a working Server Stub using swagger-codegen? I have been trying for some time, but the solution won't load in VS2017. Any idea on what I might be doing wrong? See #7892 for details on my issue. Cheers,

MCerk commented 6 years ago

Sorry, I have not yet tested the server stub. Cheers.

planbsim commented 6 years ago

@AuroraBrignola for me it looks like the "project type GUID" is incorrect Solution (.Sln) File. If you change this GUID to a valid, visual studio can load this project from the solution file.

Simple workaround would be to delete the project from your current solution and add it again as existing project - then visual studio creates a new type project GUID - and everything works fine.

best, regards

AuroraBrignola commented 6 years ago

@planbsim Thanks a lot, that worked and also made me figure out that there was an issue already opened for this, it just wasn't merged into master.

conductxr commented 6 years ago

@mandrean I've submitted a PR with the fix described above as well as another compilation issue regarding url encoding of strings.

https://github.com/swagger-api/swagger-codegen/pull/8421