swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Definition housing a Ref is not dereferencing

Open jrymal opened this issue 11 years ago • 2 comments

I know this looks awkward in JSON but the core of this is an XML description issue.

In XML schema, an XSD would have an element with a name and described as another type. In concept this does the same but does not show as such in Swagger-UI, actually it shows as "{}" with no definition at all (i'm assuming that the initial reference is successful but the subsequent one is not).

{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "Test"
    },
    "host": "127.0.0.1:9066",
    "basePath": "/ws/rest",
    "schemes": [
        "http"
    ],
    "paths": {
        "/shipOrder": {
            "post": {
                "summary": "ShipOrder",
                "consumes": [
                    "application/xml"
                ],
                "produces": [
                    "application/xml"
                ],
                "parameters": [
                    {
                        "in": "body",
                        "name": "ShipOrder ",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/shiporder"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Success"
                    }
                }
            }
        }
    },
    "definitions": {
        "shiporder": {
            "$ref": "#/definitions/shipordertype"
        },
        "shipordertype": {
            "type": "object",
            "properties": {
                "orderid": {
                    "type": "string",
                    "xml": {
                        "attribute": true
                    }
                },
                "orderperson": {
                    "type": "string"
                },
                "shipto": {
                    "$ref": "#/definitions/shiptotype"
                }
            },
            "required": [
                "orderperson",
                "shipto"
            ]
        },
        "shiptotype": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                }
            },
            "required": [
                "name"
            ]
        }
    }
}

I suppose this issue poses a separate question,

Is this expected format for this use case? (Note that this structure would make sense for reuse as the Node name is in the type, not redefined in an xml object in all possible positions)

jrymal avatar Mar 27 '15 18:03 jrymal

I assume you're referring to:

        "shiporder": {
            "$ref": "#/definitions/shipordertype"
        }

is that correct?

Can you retest it with the develop_2.0 branch?

webron avatar May 04 '15 16:05 webron

Please reopen if still an issue.

fehguy avatar May 08 '15 21:05 fehguy