0

I am working on a web server with flask/connexion and i am configuring it via a swagger.yml file. I am not allowed to show the original file but I want to do something like this in the parameters section for a post operation:

- name: someparam
  ...
  schema:
      type: object
      properties:
          someprop:
              type: object
              properties:
                  my_nested_object:
                      ...

The problem is the following: someprop is a java script object which should be saved in a json file and the key/name of my_nested_object is only known at runtime because someprop will contain more than one object of its "type". Hence the key identifies the object.

Edit: I just realized that also the count of nested objects is a problem since I don't know it at runtime either. Is there really no way to define "dynamic" objects in my swagger config?

Is there any (alternative) way to make this work?

elsamuray7
  • 79
  • 1
  • 10
  • 1
    Does this answer your question? [Swagger dictionary parameter definition](https://stackoverflow.com/q/41867499/113116) – Helen Aug 03 '20 at 08:54
  • This should solve my problem. How exactly would I use that in my context? – elsamuray7 Aug 03 '20 at 09:25
  • 1
    If `someprop` is a string-to-object map you would define it as `type: object` + `additionalProperties: {type: object}`. If it's string-to-anything map, then just `type: object` (i.e. a [free-form object](https://stackoverflow.com/q/41606152/113116)). – Helen Aug 03 '20 at 09:29
  • alright, thanks. I specified `{additionalProperties: true}` (https://swagger.io/docs/specification/data-models/dictionaries/). Don't know if it is really required since you left it out but it should basically mean that it can map to anything. – elsamuray7 Aug 03 '20 at 09:34

0 Answers0