1

I struggle with specifying the following json in swagger OpenApi 3.0:

{
  "cataloge.category_color" : [ 
      ["blue", 12, "http://examle.com/2"],
      ["yellow", 2, "http://examle.com/1"],
   ]
}

I'd like to specify a set of allowed key names for example: cataloge.category_color, cataloge.category_size, cataloge.category_manufacturer.

My first problem is how to enable dynamic key names that match my nameset?

I tried the additionalProperties approach but I don't see how I can define the value part as I want.

The second problem I have is how to specify the values for the arrays inside?

I know that I could easily use named hashes for the inner arrays, but thats not what I like to do here.

Steffen Jurrack
  • 108
  • 2
  • 6
  • 1
    Do these links answer your question? [How to write OpenAPI 3 (Swagger) specification for property name in `map` object?](https://stackoverflow.com/q/46552863/113116), [How to create different element types within Swagger Editor](https://stackoverflow.com/q/38690802/113116) – Helen Jun 05 '20 at 17:49
  • Yes for the key problem this is exactly what I was looking for. But I still don't see how to solve the array part, seems not possible to create a spec to the array like [string, integer, string] – Steffen Jurrack Jun 05 '20 at 20:36
  • See [How to define JSON array with concrete item definition for every index in OpenAPI?](https://stackoverflow.com/q/57464633/113116) – Helen Jun 05 '20 at 21:04
  • It looks like you're trying to define an enum inside swagger. I'm not sure there's a way to do this, because this isn't what swagger is for. I use Swagger to generate code, and I would define the enum in my code, although I could define the structure of the enum in swagger. Is that what you're trying to do? – MiguelMunoz Sep 18 '20 at 07:20

0 Answers0