0

I'm using Restler 3, and am trying a very basic URL routing:

GET /method/{param}

My api class method gets param as the first required parameter, but he only gets it if I pass it through the request (GET /method?param=value)

It seems from the routing docs (link: http://restler3.luracast.com/examples/_006_routing/readme.html), this should be the default behavior. I've tried also playing with Defaults::$smartAutoRouting = false; which didn't seem to work.

Starting from Restler 3, smart auto routes are created where optional parameters will be mapped to query string, required primitive types will be mapped to url path, objects ana array will be mapped to request body.

Noam
  • 3,341
  • 4
  • 35
  • 64
  • just to make sure, are you using the following format? `@url GET /method/{param}` Using RC5 or RC6? – Arul Kumaran Dec 03 '14 at 04:19
  • @Luracast I'm not sure. Can you explain what are RCx is and how can I know which one? Your format (adding @url) partially works for me, it does route {param} to the required param, but it removes the optional params from the API-explorer and adds a `REQUEST_BODY` instead. – Noam Dec 03 '14 at 07:56
  • To be more specific, if my method looks like: `function foo($reqParam, $optionalParam1=null, $optionalParam2=null)` and I put a phpdoc `@url GET /{reqParam}/method` The `optionalParam1` and `optionalParam2` don't appear in the API explorer as optional fields, and instead a `REQUEST_BODY` is added. – Noam Dec 03 '14 at 09:51
  • You can find the version by either by opening Restler.php file and looking at its comments. or by the X-Powered-By header. From your comment above I can confirm that you are using RC5. This bug is already fixed in RC6 which is in V3 branch in github. You can use that with the new Explorer class while we are fixing it in RC5. Thanks for reporting the issue :) – Arul Kumaran Dec 08 '14 at 10:52

1 Answers1

1

We have just fixed this bug in RC5. Download the update and try again!

Arul Kumaran
  • 983
  • 7
  • 23