Skip to content

Schema: Require pagination limit parameter - #9547

Merged
SchrodingersGat merged 5 commits into
inventree:masterfrom
1337joe:schema-require-limit
Apr 22, 2025
Merged

SchrodingersGat merged 5 commits into
inventree:masterfrom
1337joe:schema-require-limit

Conversation

@1337joe

@1337joe 1337joe commented Apr 21, 2025

Copy link
Copy Markdown
Contributor

I'm offering this as a possible solution to the linked issue, I don't know if it's something we want.

Problem: If a pagination limit is not provided in a list query, the response comes back as a list of all relevant objects, not a paginated wrapper object as the schema defines.

Solution: Require limit to be set on list queries. That way if you're following the schema specification when you make the call the response you get also follows the schema specification.

This completely ignores/hides the shape changing nature of the current API for list endpoints.

Fixes #9195

@netlify

netlify Bot commented Apr 21, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit c3d1cd9
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/68063502cae6cd0008f54db5
😎 Deploy Preview https://deploy-preview-9547--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 97 (🟢 up 2 from production)
Accessibility: 89 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov

codecov Bot commented Apr 21, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.36%. Comparing base (e249a21) to head (c3d1cd9).
Report is 279 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9547   +/-   ##
=======================================
  Coverage   86.36%   86.36%           
=======================================
  Files        1229     1229           
  Lines       54043    54050    +7     
  Branches     2275     2275           
=======================================
+ Hits        46672    46682   +10     
+ Misses       6796     6793    -3     
  Partials      575      575           
Flag Coverage Δ
backend 88.32% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair

matmair commented Apr 21, 2025

Copy link
Copy Markdown
Member

Looks interesting; #9481 should address this generally

@SchrodingersGat

Copy link
Copy Markdown
Member

@1337joe does this change the actual behavior of the API, or just the documentation schema? I ask because there are certainly some API endpoints where we make use of this "default" behavior and do not expect (or desire) any pagination.

@1337joe

1337joe commented Apr 21, 2025

Copy link
Copy Markdown
Contributor Author

@SchrodingersGat I made the changes in the AutoSchema class so that it would only affect the schema. The API itself will remain unchanged, but the schema will be generated with limit required.

@SchrodingersGat

Copy link
Copy Markdown
Member

Ok, thanks for the clarification. We should review which endpoints we do not want to be paginated (it is only a limited set that we use that way) and perhaps mark them as such?

However, for this PR we are just updating the documentation schema, so this looks good to go.

@SchrodingersGat
SchrodingersGat merged commit 0bf1ab2 into inventree:master Apr 22, 2025
@SchrodingersGat SchrodingersGat added api Relates to the API documentation labels Apr 22, 2025
@SchrodingersGat SchrodingersGat added this to the 1.0.0 milestone Apr 22, 2025
@1337joe
1337joe deleted the schema-require-limit branch April 22, 2025 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Relates to the API documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAPI Schema and Pagination

3 participants