OpenAPITools / OpenAPITools/openapi-generator
[BUG][csharp] missing check for status code 0 - csharp netstandard2.0
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Generated code in csharp netstandard2.0 is missing check for 0 status code (connection error)
samples/client/petstore/csharp/OpenAPIClientNetStandard/src/Org.OpenAPITools/Client/Configuration.cs
click here to jump to the Configuration.cs
public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) =>
{
var status = (int)response.StatusCode;
if (status >= 400)
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.Content),
response.Content);
}
return null;
};
Currently when there is a connection error - the response is null. This is bad because of missing logs and stacktrace.
Technically I could wrap it up or use generated {methodName}WithHttpInfoAsync and manually check the status code.
Downside - I would need to do it every time I'm using the generated code (for me its multiple apps * multiple methods)
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 samples/client/petstore/csharp/OpenAPIClientNetStandard/src/Org.OpenAPITools/Client/Configuration.cs and inspect DefaultExceptionFactory's handling of a null response during a connection error. Verify the completed behavior by exercising a connection failure and confirming that the resulting error preserves useful logs and a stack trace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100