Restler icon indicating copy to clipboard operation
Restler copied to clipboard

Namespaced response classes generates incorrect Swagger JSON

Open shaneneuerburg opened this issue 11 years ago • 1 comments

When using a class as a response type that is part of a namespace (Company\Package\Responses\MyResponse), the swagger spec is incorrectly generated.

What happens now is the swagger JSON that is generated looks like this:

"apis": [
        {
            "path": "/foo/bar",
            "operations": [
                {
                    .......
                    "type": "Company\\Package\\Responses\\MyResponse"
                }
            ]
        }
    ]

The models section of the JSON, however, is populated like so:

"models": {
        "MyResponse": {
            "id": "MyResponse",
           ......... 
        }
    }

It seems that Swagger-UI doesn't know how to match the two because of the namespacing. I'm not sure if the best fix is to namespace both (to avoid potential conflicts with larger APIs) or if namespaces should be stripped (exposing extra information that isn't useful to clients).

I'd lean towards namespacing, which I'm currently doing by removing this line: https://github.com/Luracast/Restler/blob/3.0.0-RC6/vendor/Luracast/Restler/Explorer.php#L412

shaneneuerburg avatar Jul 06 '15 23:07 shaneneuerburg

Please re-open if the issue still exists in explorer v2

Arul- avatar Aug 01 '21 15:08 Arul-