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

Query Parameters for Pagination #705

Closed
1 task done
Floppy012 opened this issue Aug 10, 2023 · 3 comments
Closed
1 task done

Query Parameters for Pagination #705

Floppy012 opened this issue Aug 10, 2023 · 3 comments
Labels
question Further information is requested

Comments

@Floppy012
Copy link
Contributor

Floppy012 commented Aug 10, 2023

Scribe version

4.22.0

Your question

Is there a way to generate the page query parameter when enabling the pagination of an API response? Or do I have to add it manually?

Docs

@Floppy012 Floppy012 added question Further information is requested triage labels Aug 10, 2023
@Floppy012 Floppy012 changed the title Request Parameters for Pagination Query Parameters for Pagination Aug 10, 2023
@shalvah
Copy link
Contributor

shalvah commented Aug 10, 2023

Not sure I understand what you mean by "enabling the pagination", but note that you can add a custom strategy to automatically add some parameters to certain endpoints. I believe there's an example in the docs.

@shalvah shalvah closed this as completed Aug 10, 2023
@shalvah shalvah removed the triage label Aug 10, 2023
@Floppy012
Copy link
Contributor Author

Not sure I understand what you mean by "enabling the pagination", but note that you can add a custom strategy to automatically add some parameters to certain endpoints. I believe there's an example in the docs.

@shalvah I'm sorry. I should've provided more information:

The docs state that one can provide attributes such as #[ResponseFromApiResource]. Those attributes have the pagination parameter. When setting that parameter, the generated response body in the documentation is that of Laravel's paginate function. paginate uses the page parameter of the HTTP request. My question was whether there is a way that this query parameter could also be generated in the documentation without having to add it manually.

@shalvah
Copy link
Contributor

shalvah commented Aug 11, 2023

Ah, no, that's not supported. I'm not sure we should support that, as it can be quite opinionated (what parameter names to use).

Btw, if you're using attributes, you can consider creating your own attribute which extends the ones provided by Scribe. This way, Scribe can read the attribute and generate the response, and you can add a custom strategy that adds the query parameters from there. (It's fairly easy if you follow the examples in Scribe.)

Heck, you don't even need a custom attribute here. Just a strategy that adds the query parameters to an endpoint if it has this attribute, if that's what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants