swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.56k stars 8.96k forks source link

Wrong mapping on path parameters when generating the request URL #831

Closed franciscogouveia closed 9 years ago

franciscogouveia commented 9 years ago

I've initially opened this issue on hapi-swaggered-ui plugin, but I think this makes more sense here.


Problem:

With such a request:

/this/{test}/is/{testABC}/a/{testABCDEF}/test/{other}/of/{otherABC}/swagger/{otherDEF}/ui

The swagger-ui generates the right parameters in the UI.

But, when I press the Try it button, the value of the parameter test is placed on all the {test*} and other is placed on all the {other*}, in the Request URL.

Example:

I made a screenshot: hapi-swaggered-ui-path-bug-1

The expected result should be:

http://192.168.2.51:80/this/id1/is/id2/a/id3/test/id4/of/id5/swagger/id6/ui


I confirmed in the hapi-swaggered-ui's node_modules folder that the swagger-ui version that is being used is 2.0.24.

webron commented 9 years ago

Thanks you.

Based on the version of the ui, I assume this is Swagger 1.2?

franciscogouveia commented 9 years ago

Correct.

I'm using hapi-swaggered, which is Swagger 1.2 compliant.

webron commented 9 years ago

Okay, I'm not sure if this is an issue with swagger-ui or swagger-js, but @fehguy would be able to say.

By the way, did you happen to check the browser's console and see if that's the actual URL being used?

franciscogouveia commented 9 years ago

I confirmed now, it is the actual URL being used:

hapi-swaggered-ui-path-bug-2

webron commented 9 years ago

:+1:

z0mt3c commented 9 years ago

Example

{
    "swaggerVersion": "1.2",
    "basePath": "http://localhost:8000",
    "resourcePath": "/foo",
    "produces": ["application/json"],
    "apis": [{
        "path": "/foo/{foo}/a/{fooA}/b/{fooB}",
        "operations": [{
            "method": "GET",
            "nickname": "get_foo_foo_a_fooA_b_fooB",
            "parameters": [{
                "required": true,
                "type": "string",
                "name": "foo",
                "paramType": "path"
            }, {
                "required": true,
                "type": "string",
                "name": "fooA",
                "paramType": "path"
            }, {
                "required": true,
                "type": "string",
                "name": "fooB",
                "paramType": "path"
            }],
            "type": "void"
        }]
    }],
    "models": {}
}
fehguy commented 9 years ago

this has been addressed in the develop_2.0 branch