NYCPlanning / ae-zoning-api

This application is API for serving data related to zoning and tax lots.
2 stars 0 forks source link

Document endpoint to get paginated tax lots #171

Closed TangoYankee closed 6 months ago

TangoYankee commented 7 months ago

Description

As part of discussion #97

Create OpenAPI documentation for an endpoint which will return a paginated list of tax lots. Pagination will utilize an offset key paradigm, which exposes the "LIMIT" and "OFFSET" sql functionality through optional query parameters of the same names. When either query parameter is omitted, the application will fall back to default values. "Limit" will also have a maximum value that will be invoked if users request a number higher than this value. The returned object will return pagination metadata.

Acceptance criteria

TylerMatteo commented 7 months ago

@TangoYankee Overall this looks good to me. Two things:

when the total is less than the limit, this indicates there are no more rows that match the overall request

Are we sure that would work reliably? If you're querying a table with 100 rows with limit 10, then the results for the last page would have 10 for the limit and the total. Put another way, would we be able to tell that we're on the last page if the total results of the overall query are evenly divisible by the limit?

How do you feel about putting the contents of your pageSchema just at the root of the response instead of nested in a page object. This would keep the responses "flatter" and feels more inline with implementations I've seen elsewhere. We could still make the implementation reusable in the OAS doc by having some sort of pagable or paginated schema that responses can be composed from.

TangoYankee commented 7 months ago

Are we sure that would work reliably? If you're querying a table with 100 rows with limit 10, then the results for the last page would have 10 for the limit and the total. Put another way, would we be able to tell that we're on the last page if the total results of the overall query are evenly divisible by the limit?

The last page would give us a total of 0, which is annoying because it means there was no value in making the request. But, it does tell us that there will be no other results.

TangoYankee commented 7 months ago

How do you feel about putting the contents of your pageSchema just at the root of the response instead of nested in a page object. This would keep the responses "flatter" and feels more inline with implementations I've seen elsewhere. We could still make the implementation reusable in the OAS doc by having some sort of pagable or paginated schema that responses can be composed from.

Makes sense. I'll make the adjustments