OpenAPITools / OpenAPITools/openapi-generator
[csharp-netcore] How to deal with different response objects?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
The Api definition specifies that for different status codes, different objects are returned. The generated client always expects a DataDeliveryReceipt object, if the response is e.g. 412, an ApiException is thrown and I see the ValidationResponse as string in the ErrorContent. I expected to get the Error Code and the ValidationResponse object. What is the intended procedure in such a case or does the generator not support that?
openapi-generator version
6.0.0
OpenAPI declaration file content or url
responses:
"200":
description: A receipt of the data received.
content:
application/json:
schema:
$ref: '#/components/schemas/DataDeliveryReceipt'
"400":
description: Processing conflicts occurred.
content:
application/json:
schema:
$ref: '#/components/schemas/ProcessingConflicts'
"401":
description: Authorization failure.
"403":
description: No permission to the requested data with the given credentials.
"412":
description: Validation errors occured.
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationResponse'
"500":
description: Technical error.
The complete .yaml File can be found here. https://arge-heiwako.de/wp-content/uploads/2022/03/arge-spec-on-site-roles_1_1.zip
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/9966
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 response definitions in the provided OpenAPI YAML and inspect how the generated C# client handles non-success responses through ApiException and ErrorContent. Read related issue #9966, then establish whether typed responses such as ValidationResponse are supported and document or implement the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100