GetShopTV/swagger2

JSON keys examples in a Schema of (Map UUID Something)?

Open

#136 opened on Dec 13, 2017

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Haskell (61 forks)github user discovery
help wanted

Repository metrics

Stars
 (74 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Sometimes it’s useful to return a Map k v from an API, e.g. when this k is some kind of a newtype over UUID, or similar.

Anyway, in such a case, the generated example value looks like:

    "accounts": {
      "additionalProp1": {
        "username": "string"
      },
      "additionalProp2": {
        "username": "string"
      },
      "additionalProp3": {
        "username": "string"
      }
    }

while the real response:

    "accounts": {
      "bff3d422-13be-48ad-b344-7e30d38c2c3f": {
        "username": "michalrus1"
      },
      "cbad52fd-96ae-4154-ad26-c8e8c8902a26": {
        "username": "michalrus2"
      }
    }

Perhaps it’d possible to have:

    "accounts": {
      "00000000-0000-0000-0000-000000000000": {
        "username": "string"
      },
      "00000000-0000-0000-0000-000000000000": {
        "username": "string"
      },
      "00000000-0000-0000-0000-000000000000": {
        "username": "string"
      }
    }

?

Now, the generated swagger.json contains:

        "accounts": {
          "additionalProperties": {
            "$ref": "#/definitions/Account"
          },
          "type": "object"
        }

Contributor guide