Skip to content

Conversation

@yelizhenden-mdb
Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb commented Mar 25, 2025

Proposed changes

Jira ticket: CLOUDP-271998 and CLOUDP-304955

This PR validates

  • if 200 OK responses of List methods refer to a schema with "Paginated" prefix. (Related guideline amendment PR: https://github.com/10gen/ipa/pull/64)
  • if 200 OK responses of List methods have a schema with results (array) fields

Clarification: The associated guideline the xgen-IPA-110-collections-response-define-results-array rule validating is The response for collections must define an array of results containing the paginated resource

This guideline is shared with xgen-IPA-105-list-method-response-is-get-method-response rule. The rule is already checking if the results array containing the paginated resource when the results array exists. Different than that, xgen-IPA-110-collections-response-define-results-array rule only checks if the List method response have a schema with results (array) fields.

Follow-up

  • Having links field following ApiListView implementation will be validated in scope of another guideline The response for collections should define an array of links field, providing the user with links to the next and previous pages
  • Having totalCount field is not required as it is mentioned in the The response for collections may provide an integer totalCount field, providing the user with the total number of resources available in the backing collection. This total may be an estimate but the API should explicitly document that
  • For all the other Pagination guidelines, refer to IPA-110: Pagination to be implemented

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

Changes to Spectral

  • I have read the README file for Spectral Updates

Further comments

@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review March 25, 2025 11:58
@yelizhenden-mdb yelizhenden-mdb requested a review from a team as a code owner March 25, 2025 11:58
@yelizhenden-mdb yelizhenden-mdb changed the title CLOUDP-271998: IPA-110: Pagination: APIs returning collections should provide pagination (Part 1) CLOUDP-271998: IPA-110: Pagination: APIs returning collections should provide pagination Mar 25, 2025
@wtrocki
Copy link
Member

wtrocki commented Mar 25, 2025

Paginated prefix is weak requirement IMHO as we do not validate that in any way.
It is derrived from the class name. Do we see classes with Paginated that do not conform to th definition of page.
If not let's remove Paginated prefix.

@wtrocki
Copy link
Member

wtrocki commented Mar 25, 2025

Assumption: If schema name starts with Paginated, it will be assumed that it extends ApiListView, and the referenced schema will not be validated

That information should be present in the openapi already. Using name as assumption might lead to false negatives.

Copy link
Member

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggesting to use reliance on the base class or check for format of the fields instead of the name.

@yelizhenden-mdb yelizhenden-mdb marked this pull request as draft March 25, 2025 14:45
@yelizhenden-mdb yelizhenden-mdb changed the title CLOUDP-271998: IPA-110: Pagination: APIs returning collections should provide pagination CLOUDP-271998: IPA-110: Pagination (Validate Paginated prefix and results array field) Mar 25, 2025
@yelizhenden-mdb yelizhenden-mdb marked this pull request as ready for review March 25, 2025 15:42
Copy link
Member

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disscussed offline. Yeliz to make changes based on new IPA proposed rule.
Unblocking

@yelizhenden-mdb yelizhenden-mdb merged commit 1448759 into main Mar 25, 2025
8 checks passed
@yelizhenden-mdb yelizhenden-mdb deleted the CLOUDP-271998 branch March 25, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants