OpenAPI 3 Dictionary Define Key & Value Types

Viewed 249

I have read https://swagger.io/docs/specification/data-models/dictionaries/, but am still having trouble modeling something like:

{
  "top": {
    "elem0": {
      ...
    },
    "elem1": {
      ...
    },
    ...
  }
}

top is a dictionary, containing an arbitrary number of entries. The trouble is that I want to define a reusable schema for the key and value types.

E.g., instead of saying that the keys are of type string, I say they are of type #/components/schemas/KEY. And instead of saying that the values are of type object, I say they are of type #/components/schemas/VALUE.

Is this possible?

0 Answers
Related