swagger-api / swagger-api/swagger-codegen

[PHP] Incorrect return types if multiple responses are defined

Open
#8,159 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Language: php
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

If you define multiple responses, the codegen will only support the first one (typically 200).

Swagger-codegen version

2.3

Swagger declaration file content or url
  /path
    post:
      responses:
        200:
          schema:
            $ref: '#/definitions/EmptyResponse'
        202:
          schema:
            $ref: '#/definitions/InBackgroundResponse'
Suggest a fix/enhancement

Correctly generate the return-object based on the HTTP Status Code in the Response.
Also fix ReturnType info in DocBlock

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

No file or test is named in the issue. Start by tracing PHP code generation for an operation with multiple responses, then inspect how response status codes determine return types and DocBlock metadata. Done means generated PHP code selects the appropriate response model for each HTTP status code and documents the resulting return type correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.