-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Added optional path parameter support #210
Conversation
{ "apis": [ { "path": "/foo(/{optional})", "operations": [ "parameters": [ { "dataType": "string", "name": "optional", "required": false, "paramType": "path" } ] ] } ] } If the optional parameter is inputted, say the value is val, the request path will become /foo/val. Otherwise the path will become /foo If one of the path parameter is set to be optional, all of the path parameter with the same must be optional. The following path: /foo(/{optional})/{optional} is invalid. invalid path exception will be throw
@fehguy . How do you think about it? I think the optional path parameter should be supported since the RESTful framework, say Slim supports the optional path parameter. |
Hey @ytsTony what happens in this scenario? You have these routes:
where |
These kind of routes would cause confusion, but I think the mechanism that handling such routes is the responsibility of the server side application. They might either forbid these case occur or have other way to deal with. As swagger, sending such request should be supported since the user knows the exact path. |
Hey @fehguy . I think the following scenario will cause the sample confusion as the one you point out with the optional path. You have these routes:
User invokes |
+1 I have this URL with an optional path param and the UI still thinks is required:
|
Take a look here for details on the spec--optional path params are not supported. |
Well, maybe the official JSR does not include it, but that was clearly a mistake, because as you can see they are needed and there are workarounds and even someone has take the trouble to give you an elegant solution. Any other argument is just stubbornness :-) |
Hi, I'm not trying to be stubborn but rather follow the swagger-1.2 spec which is quite widely distributed--design mistake or not. I STRONGLY encourage you to submit issues to the spec for improvements as that's the way to move the ball forward. |
Fair enough! I will submit an issue then :-) 👍 |
{
"apis": [
{
"path": "/foo(/{optional})",
"operations": [
"parameters": [
{
"dataType": "string",
"name": "optional",
"required": false,
"paramType": "path"
}
]
]
}
]
}
If the optional parameter is inputted, say the value is val, the
request path will become /foo/val.
Otherwise the path will become /foo
If one of the path parameter is set to be optional, all of the path
parameter with the same must be optional.
The following path:
/foo(/{optional})/{optional}
is invalid. invalid path exception will be throw