swagger-ui: Recursive definition references not working

Hi guys,

I’m hosting both swagger-editor and swagger-ui. http://vm-linuxapp-75:8080/swagger/#/ for the swagger-editor and http://vm-linuxapp-75:8080/swagger-ui/ for swagger-ui

I have the spec file below hosted at http://vm-linuxapp-75:8080/swagger/specs/occupation.json (inside the swagger-editor). The file references definitions located in http://vm-linuxapp-75:8080/swagger/definitions/occupations.json using an absolute url. This latter definition references another definition located in in http://vm-linuxapp-75:8080/swagger/definitions/map.json

Everything works fine in swagger-editor (the preview panel display all the definitions referenced). However, in swagger-ui when i try to load http://vm-linuxapp-75:8080/swagger/specs/occupation.json only the first level of definitions are loaded, the definitions referenced by these last ones are not loaded

Here is an example


// spec file
{
    "swagger": "2.0",
    "info": {
        "title": "Occupations API",
        "description": "This API manages Occupations",
        "version": "1.0.0"
    },
    "host": "localhost:8080",
    "schemes": [
        "http",
        "https"
    ],
    "basePath": "/",
    "produces": [
        "application/json",
        "application/xml"
    ],
    "paths": {
        "/occupations": {
            "post": {
                "tags": [
                    "Occupations"
                ],
                "summary": "Adds a new Occupation",
                "description": "",
                "consumes": [
                    "application/json",
                    "application/xml"
                ],
                "produces": [
                    "application/json",
                    "application/xml"
                ],
                "parameters": [
                    {
                        "name": "occupation",
                        "in": "body",
                        "description": "Occupatione object that needs to be added",
                        "required": true,
                        "schema": {
                            "$ref": "http://vm-linuxapp-75:8080/swagger/definitions/occupation.json"
                        }
                    }
                ],
                "responses": {
                    "201": {
                        "description": "M00-01 - If the record was created",
                        "schema": {
                            "$ref": "http://vm-linuxapp-75:8080/swagger/definitions/error.json"
                        }
                    },
                    "500": {
                        "description": "M00-06 - Other cases",
                        "schema": {
                            "$ref": "http://vm-linuxapp-75:8080/swagger/definitions/error.json"
                        }
                    }
                }
            }
        }
    }
}
occupation.json
{
    "properties": {
        "id": {
            "type": "string",
            "description": "Unique identifier representing a specific occupation"
        },
        "descriptions": {
            "type": "object",
            "description": "Description of the occupation",
            "properties": {
                "map": {
                    "$ref": "http://vm-linuxapp-75:8080/swagger/definitions/map.json"
                }
            }
        }
    }
}

map.json


{
    "description": "A set of key-value pairs, one key per language",
    "properties": {
        "en": {
            "type": "string"
        },
        "fr": {
            "type": "string"
        }
    }
}

The map part is not loaded by swagger ui

capture

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Recursive definitions -are- supported but the examples will be truncated. What do you see with current master that is wrong?