Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Serdes Does Not Work for Items in Object in Array

See original GitHub issue

Describe the bug Serdes performs well on properties in an object. However, when the owning object is part of an array, then serialize is never called.

To Reproduce

  1. git clone
  2. npm run deps && npm i
  3. cd express-openapi-validator/examples/7-response-date-serialization
  4. npm start
  5. GET http://localhost:3000/v1/date-time

The above works fine.

Let’s now modify the route in app.js to return an array of objects:

app.get('/v1/date-time', function (req, res, next) {
    // {
    //   id: 1,
    //   created_at: new Date(),
    // }
        id: 1,
        created_at: new Date(),

We’ll also modify the schema in api.yaml:

        description: date-time handler
#              type: object
#              properties:
#                created_at:
#                  type: string
#                  format: date-time
#                id:
#                  type: number
              type: array
                type: object
                    type: string
                    format: date-time
                    type: number

Actual behavior

    "message": ".response[0].created_at should be string",
    "errors": [
            "path": ".response[0].created_at",
            "message": "should be string",
            "errorCode": "type.openapi.validation"

Expected behavior

        "id": 1,
        "created_at": "2022-01-20T17:40:41.816Z"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

Fabiencdpcommented, Aug 31, 2022

We are waiting for the approve of the repository owner

cdimasciocommented, Nov 20, 2022

This is now available in v5.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Array.includes() to find object in array - Stack Overflow
Array.includes compares by object identity just like obj === obj2 , so sadly this doesn't work unless the two items are references to...
Read more >
Kafka Streams Data Types and Serialization
Every Kafka Streams application must provide Serdes (Serializer/Deserializer) for the data types of record keys and record values (e.g. java.lang.String or Avro ...
Read more >
cocobelgica/AutoHotkey-SerDes: Serialize / de ... - GitHub
Serilaized output is similar to JSON except for escape sequences which follows AHK's specification. · Non-standard AHK objects such as COM, Func, FileObject, ......
Read more > - JavaScript | MDN - MDN Web Docs
Objects created from built–in constructors like Array and Object have ... In general, it is best not to add, modify, or remove properties...
Read more >
Querying arrays with complex types and nested structures
When you query tables within Athena, you do not need to create ROW data types, ... within an element inside an array, using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found