Skip to content

Date is not validated correctly as type: string, format: date-time #246

Closed
@severinwullschleger

Description

@severinwullschleger

Hi

I want to return the created and lastModified timestamp from the database which I define in my ORM with type Date.

If I print the response object in my express router before returning it, it looks like this:

User {
   id: '1fe87c1d-5d31-4426-8757-aa5e62d2344e',
   lastModified: 2020-02-21T09:26:43.603Z,
   created: 2020-02-21T09:25:48.151Z,

If I call the endpoint I get the following reponse object:

{
  "data": [
    {
      "id": "1fe87c1d-5d31-4426-8757-aa5e62d2344e",
      "lastModified": "2020-02-21T09:26:43.603Z",
      "created": "2020-02-21T09:25:48.151Z"
    },
...

-> correctly stringified

As soon as I set the validateResponses option in the OpenApiValidator on true, I get the following error message:

{
  "error": ".response.data[0].lastModified should be string, .response.data[0].created should be string,

... although it is a string in the upper example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions