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
  • #2199
Closed
Open
Issue created Feb 20, 2019 by Administrator@rootContributor

[PHP] nullable attribute with value null gets removed

Created by: githubERIK

Description

Given a nullable field in OpenAPI object

    SomeObject:
      type: object
      properties:
        someProperty:
          type: string
          nullable: true

When HTTP Request has the object and it includes someProperty=null.

Then the generated php client code does not include someProperty in the response.

openapi-generator version

master branch (version 3.3.4) EDIT: also version 4.0.3

OpenAPI declaration file content or url

See the description

Command line used for generation

openapi-generator generate -g php

Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Remove null-check if-block if ($value !== null) from https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/php/ObjectSerializer.mustache#L68

by changing this

if ($value !== null) {
    $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
}

to this

$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]);
Assignee
Assign to
Time tracking