Skip to content

Are regex wildcards supported in path? #502

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

Closed
nikhiljindal opened this issue Nov 4, 2015 · 5 comments
Closed

Are regex wildcards supported in path? #502

nikhiljindal opened this issue Nov 4, 2015 · 5 comments

Comments

@nikhiljindal
Copy link

Is /resources/static/{subpath:*} a valid value for the path?
If yes, then what should be the name of the path param subpath or subpath:*

Here is an example spec:

{
  "swaggerVersion": "1.2",
  "apiVersion": "",
  "basePath": "http://localhost",
  "resourcePath": "/resources",
  "apis": [
   {
    "path": "/resources/static/{subpath:*}",
    "description": "",
    "operations": [
     {
      "type": "void",
      "method": "GET",
      "nickname": "staticFromPathParam",
      "parameters": [
       {
        "type": "string",
        "paramType": "path",
        "name": "subpath",
        "description": "subpath of the resource",
        "required": true,
        "allowMultiple": false
       }
      ]
     }
    ]
   }
  ],
  "models": {}
 }

which fails swagger-tools validate with:

API Declaration (/resources) Errors:

    #/apis/0/operations/0/parameters/0/name: API path parameter could not be resolved: subpath
    #/apis/0/path: API requires path parameter but it is not defined: subpath:*

2 errors and 0 warnings

cc @webron @wing328

@webron
Copy link
Member

webron commented Nov 4, 2015

That's not supported by the spec. You can regex the value of it, but not the name itself.

@nikhiljindal
Copy link
Author

I want to regex the value.
I want to express that all paths of the form /resources/static/* are correct i.e
/resources/static/a is a valid path, with subpath=a
/resources/static/a/b is also a valid path, with subpath=a/b
How do I do that?

How does the spec differentiate this case with the one where only /resources/static/a is valid and /resources/static/a/b is not?

@webron
Copy link
Member

webron commented Nov 4, 2015

That wasn't what I was referring to by regexing the value. "/" is not valid in the value of a path parameter. We don't support that part of RFC 6570. See #291 (and others) for more information.

@nikhiljindal
Copy link
Author

#291 is exactly what I am looking for!
I guess I will just +1 that.
Closing this, thanks for the prompt reply.

PS: We have been using this for a long time by naming our path param subpath:*. swagger-tools validate passes, but ofcourse the generated client code is messed up, it has code like public String staticFromPathParam(String subpath:*))

@Nikoolayy1
Copy link

This seems related to #892

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

3 participants