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 to the same definition only works on the first property #934

Closed
tlbdk opened this issue Feb 13, 2015 · 5 comments
Closed

$ref to the same definition only works on the first property #934

tlbdk opened this issue Feb 13, 2015 · 5 comments

Comments

@tlbdk
Copy link

tlbdk commented Feb 13, 2015

I'm having an issue with references to the same definition only showing up on the first property, all properties after just get the name of the definition, see the attached screenshot to see the issue.

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "Test sample showing swagger error",
        "description": "Show that $ref to the same defination only works on the first property",
        "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/badgerfishstring"
                }
            }
        },
        "badgerfishstring": {
            "required": [
                "$"
            ],
            "properties": {
                "$": {
                  "type": "string"
                }
            }
        }
    }
}

image

@fehguy
Copy link
Contributor

fehguy commented Feb 13, 2015

Are you using swagger-ui 2.1.4-M1?

@tlbdk
Copy link
Author

tlbdk commented Feb 13, 2015

Just updated to v2.1.4-M1 and seeing same issue

@JohanBas
Copy link

I have the same issue with version 1.2

@x12a1f
Copy link

x12a1f commented Feb 19, 2015

This seems to be a duplicate of #904

fehguy added a commit to swagger-api/swagger-js that referenced this issue Feb 20, 2015
@fehguy
Copy link
Contributor

fehguy commented Feb 20, 2015

this is tested and fixed in 2.1.6-M1 of swagger UI. tests are here:

https://github.com/swagger-api/swagger-js/blob/c16f45196f4749071c794babae136b45655ec399/test/models.js#L204

Not sure if the 1.2 support can be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants