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

Support for /$count operation #223

Open
Tiberriver256 opened this issue Sep 24, 2022 · 4 comments
Open

Support for /$count operation #223

Tiberriver256 opened this issue Sep 24, 2022 · 4 comments

Comments

@Tiberriver256
Copy link

https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_RequestingtheNumberofItemsinaCollect

Is there existing support for this? I'm not seeing it in the output and can't find any parameters to enable it.

I'm using the tools/V4-CSDL-to-OpenAPI.xsl

@ralfhandl
Copy link
Contributor

Hi Micah,

Currently there are no path items produced for /$count requests. The OpenAPI files only describe the "basic" requests and are intended as a gentle introduction, not a full enumeration of all possible requests.

If you see the need for optionally adding these, please contribute this feature.

Thanks in advance
Ralf

@Thorbenl
Copy link

Thorbenl commented May 31, 2023

Hey @ralfhandl :)
Is there any chance you and the team will be working on this? It would be a much appreciated endeavor, that would make our lives here a lot easier :)

@ralfhandl
Copy link
Contributor

ralfhandl commented May 31, 2023

Hi @Thorbenl,

Could you please explain how this would make your lives easier?

Background for my question: a typical use for the count of a collection is showing a table with some rows and a heading containing the total number of rows:

image

This is best implemented by requesting the initial set of rows plus the total count in one request

GET /Products?$count=true&$top=20

Sending two requests, one for the top 20, and one for the total count, is IMHO an anti-pattern. Which is why the tool does not advertise the /$count operation and only advertises the combined GET with $top and $count=true.

Thanks in advance

@Thorbenl
Copy link

Thorbenl commented Jun 1, 2023

Hi @ralfhandl
First and foremost, thanks for the elaborate answer. I do think the frontend we use is just using it wrong then, since the "issue" is that the frontend does the /$count, instead of doing it on the entity as you mentioned - /products?PAGINATIONSTUFFF&$count=true

Thanks for making that clear - I do not think we need anything here then, but change the frontend and tell the engineers to change it to the more streamlined approach.

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

No branches or pull requests

3 participants