Forum Discussion

lia's avatar
New Contributor
2 years ago

Dictionaries mapping strings to Array?

Hello, you all. I aim to generate the spec through a NestJS project, and It's all working until now. The problem arises when I want to specify that return data is a Dict that maps a key to an array of custom objects.


I read the documentation here and some related content and got that I can create a map of strings to strings as:

type: object
  type: string

 but in, all examples I found I couldn't relate to an Array.

This is an example of my data:

  "1":[CustomObjectType, CustomObjectType, CustomObjectType],
  "5":[CustomObjectType, CustomObjectType, CustomObjectType]

 So I think on Swagger it should be something like:

      type: object
        $ref: '#/components/schemas/CustomObjectType'
        isArray: true

      type: object

But I can't get it correctly. If I discover how I do it in Swagger, I can figure it out how to pass it to NestJS.

Thank you to anyone who can help me. 

2 Replies

    • lia's avatar
      New Contributor

      Thank you, ponelat, it totally solved my problem, it was exactly that. I thought that maybe an Array type would fit, but I had no idea how to specify the item's type. It seems very clear now. ğŸ˜¸