Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Running Generate From Schema on a Model with a unique array constraint of enums causes Stoplight to hang #368

Open
pazaan opened this issue Feb 20, 2019 · 0 comments

Comments

@pazaan
Copy link

pazaan commented Feb 20, 2019

Given the following model:

{
  "type": "object",
  "title": "New User Details",
  "properties": {
    "username": {
      "type": "string",
      "format": "email"
    },
    "emails": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "format": "email"
          }
        ],
        "type": "string"
      }
    },
    "password": {
      "type": "string",
      "format": "password"
    },
    "roles": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "enum": [
              "clinic"
            ]
          }
        ],
        "type": "string"
      }
    }
  },
  "required": [
    "username",
    "emails",
    "password",
    "roles"
  ]
}

If I have a PATH that takes a Request Body that is a $ref to the model, and push the Generate From Schema button, an example is generated exactly as I expect it to be (albeit with duplicates).

If I change the model to the following:

{
  "type": "object",
  "title": "New User Details",
  "properties": {
    "username": {
      "type": "string",
      "format": "email"
    },
    "emails": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "anyOf": [
          {
            "format": "email"
          }
        ],
        "type": "string"
      }
    },
    "password": {
      "type": "string",
      "format": "password"
    },
    "roles": {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "enum": [
              "clinic"
            ]
          }
        ],
        "type": "string"
      }
    }
  },
  "required": [
    "username",
    "emails",
    "password",
    "roles"
  ]
}

Then the example is still generated as expected (still with potentially duplicate roles).

If I use the following model:

{
  "type": "object",
  "title": "New User Details",
  "properties": {
    "username": {
      "type": "string",
      "format": "email"
    },
    "emails": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "anyOf": [
          {
            "format": "email"
          }
        ],
        "type": "string"
      }
    },
    "password": {
      "type": "string",
      "format": "password"
    },
    "roles": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "anyOf": [
          {
            "enum": [
              "clinic"
            ]
          }
        ],
        "type": "string"
      }
    }
  },
  "required": [
    "username",
    "emails",
    "password",
    "roles"
  ]
}

Pressing Generate From Schema now causes Stoplight Next to hang. This happens both in the Desktop app, and on the website.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant