Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5576
Closed
Open
Issue created Mar 11, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] [php-symfony] Response Content for Status-Codes >= 300 ignored

Created by: HCrane

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

When returning a Status code above 300 the result won't be sent to the user in the request body although explicitly stated in the *.yaml file used for generation

openapi-generator version

4.2.3

OpenAPI declaration file content or url

Minimized yaml file can be found here: https://gist.github.com/dmetzner/3b5d2e3f1ce637a618d932563dc5cbcb

Command line used for generation
java -jar ../openapi-generator-cli.jar generate \
-i testing.yaml \
-g php-symfony \
-p sortParamsByRequiredFlag=true \
-p skipFormModel=true \
-p variableNamingConvention=camelCase \
-p phpLegacySupport=false
Steps to reproduce

Just generating with the given yaml file, and looking directly in ./Controller/UserController.php. At the end of the function you should see something like this:

$result = $handler->userPost($inlineObject, $responseCode, $responseHeaders);
// Find default response message
$message = 'User successfully registered.';
// Find a more specific message, if available
switch ($responseCode) {
    case 201:
        $message = 'User successfully registered.';
        break;
    case 400:
        $message = 'BAD Request - invalid or missing required parameters';
        break;
    case 415:
        $message = 'Unsupported Media Type - request must use application/json as content type';
        break;
    case 422:
        $message = 'Unprocessable Entity';
        break;
}
return new Response(
    '',
    $responseCode,
    array_merge(
        $responseHeaders,
        [
            'X-OpenAPI-Message' => $message
        ]
    )
);

As you can see result is simply ignored.

Related issues/PRs

Not to my knowledge no.

Suggest a fix

It should look like a response from a 200 Status code like this:

return new Response(
    $result !== null ?$this->serialize($result, $responseFormat):'',
    $responseCode,
    array_merge(
        $responseHeaders,
        [
            'Content-Type' => $responseFormat,
            'X-OpenAPI-Message' => $message
        ]
    )
);
Assignee
Assign to
Time tracking