Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP] Date isn't correctly formatted #865

Open
a4blue opened this issue Feb 19, 2021 · 0 comments
Open

[PHP] Date isn't correctly formatted #865

a4blue opened this issue Feb 19, 2021 · 0 comments

Comments

@a4blue
Copy link

a4blue commented Feb 19, 2021

Description

Date is not correctly formatted from a DateTime Object in a generated PHP-Client
Expected was 'Y-m-d' instead 'Y-m-d\TH:i:sP' was generated

Swagger-codegen version
  • 3.0.24
  • git commit 912afd4052f5bb37064ba9e604e2ab1027eb83cf (swagger-codegen)
Swagger declaration file content or url

https://gist.github.com/a4blue/db06f076317ac6150a65b682e971039b

Command line used for generation

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i ../test.yml -l php -o ../test_api

Steps to reproduce
<?php
include_once "vendor/autoload.php";

$model = new \Swagger\Client\Model\Model();
$model->setSampleDate(new DateTime());
var_dump((string)$model);
Related issues/PRs

swagger-api/swagger-codegen#6533
swagger-api/swagger-codegen#6474
swagger-api/swagger-codegen#5607

Suggest a fix/enhancement

In lib/ObjectSerializer.php:
Line 74

- $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $swaggerType, $formats[$property]);
+ $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $formats[$property], $swaggerType);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant