Skip to content
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

Method signature instead of RequestParameters #153

Open
tprochazka opened this issue Feb 1, 2021 · 1 comment
Open

Method signature instead of RequestParameters #153

tprochazka opened this issue Feb 1, 2021 · 1 comment

Comments

@tprochazka
Copy link

I'm migrating my app from using great Drahak\Restful, because this library is sadly not maintained.
It was able to automatically map request to method parameters and obtain type and default value from it.

So instead of

/**
 * @Path("/users")
 * @Method("GET")
 * @RequestParameters({
 *      @RequestParameter(name="page", in="query", type="int")
 * })
 */
public function index(ApiRequest $request, ApiResponse $response): ApiResponse {

	$page = $request->getParameter("page", 1);

Was possible to just provide type and default value by signature like that

/**
 * @Path("/users")
 * @Method("GET")
 */
public function index(int $page = 1): ApiResponse {

Only additional attributes can be provided by annotation.
Why so the verbose approach was used by Apitte?

@f3l1x
Copy link
Member

f3l1x commented Feb 1, 2021

Hi. Unfortunately no, this relies on PSR-7 + middlewares, so you receive request object as parameter. You can drain whatever you need from ApiRequest, URL parameters, query parameters, headers, whatever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants