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
  • #2204
Closed
Open
Issue created Feb 20, 2019 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] PHP sends boolean params as "1" or "" instead of "true" or "false"

Created by: jacobweber

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 params are of type "boolean", they should be sent as "true" or "false", but the PHP generator sends them as "1" or "". But it correctly documents the parameters as @param bool. So if you send boolean parameters, it ends up doing something like (string) true, which evaluates to 1.

openapi-generator version

4.0.0-SNAPSHOT

OpenAPI declaration file content or url

https://gist.github.com/jacobweber/e83874fbf1c0ee6ede79100a7507e11f

Command line used for generation

java -jar openapi-generator.jar generate -i <url> -g php -o /path/to/output

Steps to reproduce
  1. Build the above spec.
  2. Run composer install from the output dir.
  3. Run the "Getting Started" example code in README.md:
$admin = True; // bool | Include admin users?
try {
    $result = $apiInstance->usersGet($admin);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->usersGet: ', $e->getMessage(), PHP_EOL;
}
  1. It calls GET http://localhost/api/users?admin=1 instead of GET http://localhost/api/users?admin=true.
Related issues/PRs

N/A

Suggest a fix

Detect booleans and convert to "true" or "false".

Assignee
Assign to
Time tracking