temando / serverless-openapi-documentation

Serverless 1.0 plugin to generate OpenAPI V3 documentation from serverless configuration
MIT License
93 stars 127 forks source link

Recursive models are not supported #35

Open Deadarius opened 5 years ago

Deadarius commented 5 years ago

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"
    }
    }
    }
  2. reference schema in serverless documentation
  3. run serverless openapi generate

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