Skip to content

In php, date type query parameters formatted as date-time #5080

Closed
@paul-utley

Description

@paul-utley
Description

When using a parameter with the format 'date', it is incorectly formatted as a date-time. In my situation, we're passing 2 dates in the query parameters, and our api is receiving the parameters formatted as date-time and rejecting the request.

openapi-generator version

Version 4.2.0

OpenAPI declaration file content or url
"parameters": [{
                        "type": "string",
                        "format": "date",
                        "in": "query",
                        "name": "start_date"
                    },
                    {
                        "type": "string",
                        "format": "date",
                        "in": "query",
                        "name": "end_date"
                    }
                ]
Command line used for generation

openapi-generator generate -i test.json -g php -o .

Steps to reproduce
  1. Use the parameters array from above to generate a simple api definition to do a get request.

If you look at where the query parameters are serialized, you can see that the object serializer formats the datetime object as a ISO8601 date regardless if the query parameter is defined as a date or datetime type in the api definition.

Related issues/PRs

This following issue in TypeScript is exactly what I am experiencing. I just wanted to see that it was reported in php as well.
#4763

Suggest a fix/enhancement

Need a way to pass the format from the query parameter to the object serializer so it can format it correctly as a date i.e. 2020-01-01 vs a datetime i.e. 2020-01-01T00:00:00Z

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions