Skip to content

Circular references in Definitions Object #822

@vanderlee

Description

@vanderlee

Syntactically, it seems possible to construct an infinite circular reference using Definitions Objects.

Obviously, such a reference could never actually be called or returned. I can't find any conclusive answer on this in the specs. The editor at http://editor.swagger.io/ seems to accept it as valid syntax, but produces an undefined Schema.

How should such a situation be treated?

Example

{
    "swagger": "2.0",
    "info": {
        "title": "vanderlee/PHPSwaggerGen",
        "version": "2.3.7"
    },
    "host": "example.com",
    "basePath": "\/base",
    "paths": {
        "\/customers": {
            "get": {
                "tags": [
                    "Test"
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#\/definitions\/Person"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "Address": {
            "type": "object",
            "required": [
                "city",             
        "occupant"
            ],
            "properties": {
                "city": {
                    "type": "string"
                },
                "occupant": {
                    "$ref": "#\/definitions\/Person"
                }
            }
        },
        "Person": {
            "type": "object",
            "required": [
                "name",
                "home"
            ],
            "properties": {
                "name": {
                    "type": "string"
                },
                "home": {
                    "$ref": "#\/definitions\/Address"
                }
            }
        }
    },
    "tags": [
        {
            "name": "Test"
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions