serverless-openapi-documentation icon indicating copy to clipboard operation
serverless-openapi-documentation copied to clipboard

Recursive models are not supported

Open Deadarius opened this issue 6 years ago • 0 comments

Atttempts to use JSON schemas with definitions that are referencing themselves leads to stack overflow and crash.

Steps to reproduce:

  1. create a schema:
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "folder": {
      "type": "object",
      "title": "Folder Schema",
      "properties": {
        "id": {
          "type": "string",
          "example": "3ba1c69c-3c81-4d6d-b304-873d898b2e3c",
          "format": "uuid"
        },
        "name": {
          "type": "string",
          "example": "Level 1"
        },
        "folders": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/folder"
          }
        }
      },
      "additionalProperties": false,
      "required": ["id", "folders"]
    }
  },
  "type": "object",
  "title": "Folders Response Schema",
  "properties": {
    "data": {
      "$ref": "#/definitions/folder"
    }
  }
}
  1. reference schema in serverless documentation
  2. run serverless openapi generate

Outcome: Error(maximum call stack size exceeded) Expected: openapi document is generated

Deadarius avatar Apr 30 '19 20:04 Deadarius