Swagger-UI Maximum call stack size exceeded -> Backreference

时间:2017-05-02 12:11:48

标签: swagger swagger-ui

When calling my swagger.json from the swagger-ui I get an error:

Maximum call stack size exceeded

I guess it is because I have

Token which has an owner of Type User

User which has a Token of Type Token

When using the online-version of the swagger editior it can resolve the types. How can I configure swagger to resolve the types correctly?

The full swagger.json

{
    "swagger": "2.0",
    "info": {
        "description": "Descr",
        "version": "1.0.0",
        "title": "Skeleton"
    },
    "host": "1.1.1.1:11",
    "basePath": "/api",
    "tags": [{
            "name": "auth"
        }
    ],
    "schemes": ["http"],
    "paths": {
        "/auth/local": {
            "post": {
                "tags": ["auth"],
                "summary": "Authenticates User",
                "description": "This auths only local users",
                "operationId": "authenticateUser",
                "consumes": ["application/json"],
                "produces": ["application/json"],
                "parameters": [{
                        "in": "body",
                        "name": "body",
                        "required": false,
                        "schema": {
                            "$ref": "#/definitions/Credentials"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "successful operation",
                        "schema": {
                            "$ref": "#/definitions/AuthResponse"
                        }
                    }
                }
            }
        },
        "/auth/ldap": {
            "post": {
                "tags": ["auth"],
                "operationId": "authenticateLdapUser",
                "produces": ["application/json"],
                "parameters": [{
                        "in": "body",
                        "name": "body",
                        "required": false,
                        "schema": {
                            "$ref": "#/definitions/Credentials"
                        }
                    }
                ],
                "responses": {
                    "default": {
                        "description": "successful operation"
                    }
                }
            }
        }
    },
    "definitions": {
        "AuthResponse": {
            "type": "object",
            "properties": {
                "issued": {
                    "type": "string",
                    "format": "date-time"
                },
                "responseType": {
                    "type": "string",
                    "enum": ["RESPONSE", "ERROR", "UNAUTHORIZED", "OK"]
                },
                "responseDescription": {
                    "type": "string"
                },
                "accessToken": {
                    "$ref": "#/definitions/Token"
                },
                "resourceName": {
                    "type": "string"
                }
            }
        },
        "Note": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "integer",
                    "format": "int32"
                },
                "content": {
                    "type": "string"
                },
                "modified": {
                    "type": "string",
                    "format": "date-time"
                }
            }
        },
        "Token": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "expirationDate": {
                    "type": "string",
                    "format": "date-time"
                },
                "issued": {
                    "type": "string",
                    "format": "date-time"
                },
                "expired": {
                    "type": "boolean"
                },
                "owner": {
                    "$ref": "#/definitions/User"
                }
            }
        },
        "User": {
            "type": "object",
            "properties": {
                "username": {
                    "type": "string"
                },
                "password": {
                    "type": "string"
                },
                "email": {
                    "type": "string"
                },
                "displayName": {
                    "type": "string"
                },
                "notes": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Note"
                    }
                },
                "accessToken": {
                    "$ref": "#/definitions/Token"
                }
            }
        },
        "Credentials": {
            "type": "object",
            "properties": {
                "user": {
                    "type": "string"
                },
                "password": {
                    "type": "string"
                }
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,我删除了 format: date-time 并且错误消失了。 我仍然不知道是什么导致了错误。但如果没有这种格式,一切都会好起来的。