swagger-api / swagger-api/swagger-codegen
C# code generation project does not compile (but here is the fix)
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
The code generated on website https://editor.swagger.io/ for csharp is wrong
(i did not test for csharp-dotnet2)
I did one thing to make the code to compile :
In file ApiClient.cs I added the method:
public FileParameter ParameterToFile(string name, byte[] bytes)
{
return FileParameter.Create(name, bytes, "no_file_name_provided");
}
Now, at runtime there is still an error (related to RestSharp dependency),
I got this (mesage translated to english):
System.UriFormatException: 'URI not valid: Cannot determinate URI format'
on the line
RestClient = new RestClient(basePath);
in the constructor
public ApiClient(String basePath = "/")
So I changed in Configuration.cs:
BasePath = "/";
by
BasePath = "http://localhost";
Note also that the code does not compile if we update RestSharp to the latest stable version
(106.10.1 currently)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated ApiClient.cs and Configuration.cs described in the report, then compare the C# output from editor.swagger.io with the RestSharp version in use. Reproduce the compilation failure, the basePath runtime error, and the latest-RestSharp incompatibility; done means the generated project compiles and initializes without those errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100