OpenAPITools / OpenAPITools/openapi-generator
API does not have a return value. but API spec has
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Generated API does not return the HTTP response code.
As shown below, the API specification has responses 200 and 400; however, when the addTeam() API is generated, it is generated with the return type 'void'.
I want to handle the response code 200 and/or 400. Does it mean I have explicitly, define the payload type in the response specification? Can someone please provide more details on how my 'responses' specification should be?
openapi generator 3.2.0
Swagger declaration file content or url
49 /switches:
50 post:
51 summary: Add team
52 operationId: addTeam
53 requestBody:
54 description: Team detail being added
55 content:
56 application/json:
57 schema:
58 type: array
59 items:
60 $ref: "#/components/schemas/addTeamPayload"
61 responses:
62 200:
63 description: Ok
64 400:
65 description: Bad request
66 tags:
67 - Team
Command line used for generation
java -jar openapi-generator-cli-3.2.0.jar generate -i teamApiSpec.yaml -g java
Generated Java code:
/**
* Add team
*
* @param body Team detail being added (optional)
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void addTeam(List<AddTeamPayload> body) throws ApiException {
addTeamWithHttpInfo(body);
}
/**
* Add Team
*
* @param body Team detail being added (optional)
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> addTeamWithHttpInfo(List<AddTeamPayload> body) throws ApiException {
com.squareup.okhttp.Call call = addTeamValidateBeforeCall(body, null, null);
return apiClient.execute(call);
}
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 teamApiSpec.yaml and reproduce generation using openapi-generator-cli-3.2.0.jar with the Java generator. Inspect the generated addTeam and addTeamWithHttpInfo entry points, then determine the expected handling of the documented 200 and 400 responses. Done means the generated API behavior matches the response specification and is covered by an appropriate generator test or documented resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100