Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ref definition does not work in structures nested to more then one level #1003

Closed
tlbdk opened this issue Mar 5, 2015 · 3 comments
Closed
Milestone

Comments

@tlbdk
Copy link

tlbdk commented Mar 5, 2015

This is a continuation of #934, nested $ref $ref definition does not work in structures nested to more then one level.

image

Sample showing the issue:

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "Test sample showing swagger error",
        "description": "Show that $ref to the same definition only works to a certain level",
        "contact": {
            "name": "Troels Liebe Bentsen",
            "email": "[email protected]"
        }
    },
    "host": "localhost",
    "basePath": "/",
    "schemes": [
        "http"
    ],
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "paths": {
        "/test": {
            "post": {
                "summary": "Test",
                "description": "Test stuff",
                "operationId": "doTest",
                "parameters": [
                    {
                        "in": "body",
                        "name": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/test"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Test stuff response",
                        "schema": {
                          "$ref": "#/definitions/test"
                        }
                    },
                    "405": {
                        "description": "Invalid input"
                    }
                },
                "tags": ["test"]
            }
        }
    },
    "definitions": {
        "test": {
            "required": [
                "test1"
            ],
            "properties": {
                "test1": {
                    "$ref": "#/definitions/badgerfishstring"
                },
                "test2": {
                    "$ref": "#/definitions/badgerfishstring"
                },
                "test3": {
                    "$ref": "#/definitions/testNested"
                }
            }
        },
        "testNested": {
            "required": [
                "test4"
            ],
            "properties": {
                "test4": {
                    "$ref": "#/definitions/badgerfishstring"
                },
                "test5": {
                    "$ref": "#/definitions/badgerfishstring"
                },
                "test3": {
                    "$ref": "#/definitions/testMoreNested"
                }
            }
        },
        "testMoreNested": {
            "required": [
                "test6"
            ],
            "properties": {
                "test6": {
                    "$ref": "#/definitions/badgerfishstring"
                },
                "test7": {
                    "$ref": "#/definitions/badgerfishstring"
                }
            }
        },
        "badgerfishstring": {
            "required": [
                "$"
            ],
            "properties": {
                "$": {
                  "type": "string"
                }
            }
        }
    }
}
@Smolations
Copy link

This may also be a duplicate of #975. I'm sure this issue and the other two mentioned are all related...

@fehguy fehguy modified the milestone: v2.1-M2 Mar 7, 2015
@mohsen1
Copy link
Contributor

mohsen1 commented Mar 16, 2015

This is still an issue in develop_2.0

@whitlockjc please take a look at how we resolve refs in swagger-js

Here is a better example to reproduce this issue:

---
swagger: '2.0'
info:
  version: 0.0.0
  title: Simple API
paths:
  /:
    get:
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/GrandParent'
definitions:
  GrandParent:
    type: object
    properties:
      Parent:
        $ref: '#/definitions/Parent'
  Parent:
    type: object
    properties:
      Child:
        $ref: '#/definitions/Child'
  Child:
    type: object
    properties:
      name:
        type: string

@mohsen1
Copy link
Contributor

mohsen1 commented Mar 16, 2015

Please follow this issue here:
swagger-api/swagger-js#270

@mohsen1 mohsen1 closed this as completed Mar 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants