OpenAPITools / OpenAPITools/openapi-generator
[BUG][CSHARP][GENERICHOST] Failed API calls do not throw ApiExceptions
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
There is a question as to whether or not we want to do this, but current behavior in the generichost generator does not throw ApiException at any time (but it does define an ApiException class). In the RestSharp generator, if an API call resulted with a code greater than 400 (or 0, so just a failed request), it would throw an ApiException.
Do we want to recreate this behavior in generichost?
openapi-generator version
7.14.0
Generation Details
You can check the generated samples, there is no code path that results in an ApiException being thrown.
Steps to reproduce
Generate samples on master and observe the code.
Suggest a fix
@devhl-labs
My suggestion would be to follow the pattern of the RestSharp generator which had an ExceptionFactory in the Configuration object (obviously we would need to change implementation details but I'm happy to put something up for review).
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 by inspecting generated samples from the generichost generator and confirm that failed API calls have no path throwing ApiException. Compare the RestSharp generator's Configuration and ExceptionFactory pattern, then determine the intended behavior before implementing an equivalent approach. Done means failed requests and responses consistently follow the agreed ApiException behavior, with coverage in the relevant generated samples or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100