OpenAPITools / OpenAPITools/openapi-generator

Jaxrs-cxf generator generated code is not supporting different success codes

Open
#1,568 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

When we have defined 201 status code for POST success response. The interface is generated with return type mentioned in the response but always sends 200 status code instead of 201.

openapi-generator version

org.openapitools:openapi-generator-maven-plugin:3.3.1

OpenAPI declaration file content or url

post:
summary: Create a pet
operationId: createPets
tags:

  • pets
    responses:
    '201':
    description: Created
    content:
    application/json:
    schema:
    $ref: #/components/schemas/responseWithId

Generated interface looks like below:
public ResponseWithId createPets(Pet pet) {
....
}

Command line used for generation

N/A

Steps to reproduce

Configure the plugin and language as below and run mvn clean install command.
org.openapitools:openapi-generator-maven-plugin:3.3.1
<language>jaxrs-cxf</language>

Related issues/PRs

N/A

Suggest a fix/enhancement

If it can use jaxrs.ws.Response as the return type instead of the Pojo, it will be good enough for usage.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the openapi-generator Maven plugin using the jaxrs-cxf language and the provided POST response declaration, then inspect the generated interface. Done means a declared 201 success response is represented in generated behavior rather than always returning HTTP 200, while preserving the response payload type.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.