OpenAPITools / OpenAPITools/openapi-generator
[REQ] C generator: access to body and status
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
With the C generator, returned data is lost when response_code != 200.
Describe the solution you'd like
When using C generated code, I would like to have access to apiClient->response_code and
apiClient->dataReceived when response_code is not 200.
Describe alternatives you've considered
With the python generated code, whenever response_code is not 200, an exception is raised. The exception has fields containing:
self.status = http_resp.status
self.reason = http_resp.reason
self.body = http_resp.data
self.headers = http_resp.getheaders()
Additional context
YAML that can be used for an example:
openapi: '3.0.0'
info:
version: 1.0.0
title: C issue with default responses
contact:
name: Michele Albano
email: mialb@cs.aau.dk
license:
name: Eclipse
url: https://www.eclipse.org/legal/epl-2.0/
servers:
- url: "192.168.115.3:8442/whatever"
paths:
/call1:
post:
description: Call returning multiple types
operationId: call1
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type1'
responses:
200:
description: Returned data when everything is fine
content:
application/json:
schema:
$ref: '#/components/schemas/type1'
300:
description: Second possible response
content:
application/json:
schema:
$ref: '#/components/schemas/type2'
400:
description: Cute error
default:
description: Unexpected error
components:
schemas:
type1:
type: object
required:
- udp
properties:
udp:
type: boolean
type2:
type: object
required:
- yesorno
properties:
yesorno:
type: boolean
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
Use the supplied OpenAPI YAML to generate a C client and inspect the generated response-handling path, especially the apiClient response_code and dataReceived fields. Reproduce a non-200 response and define done as preserving access to its status and body, including for responses such as 300, 400, and default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100