Allow pagination=none for recursive tree API

Merged Chad Woolley requested to merge caw-remove-pagination-from-repo-tree-recursive-api into master

What does this MR do and why?

Allows pagination to be set to 'none' for /projects/:id/repository/tree API endpoint, only if recursive is set to true.

See details in related issue: Remove pagination from recursive form of /proje... (#365996 - closed)

See also related discussion in slack thread: https://gitlab.slack.com/archives/CB3LSMEJV/p1657667442291659

Screenshots or screen recordings

Example validation error when attempting to set validation=none if recursive=false:

http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=false&pagination=none

HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Content-Type: application/json
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 01G87CKRJ0D1NF2484PAT8FSMG
X-Runtime: 0.890871
Date: Mon, 18 Jul 2022 00:51:28 GMT
Content-Length: 70

{
  "error": "pagination cannot be \"none\" unless \"recursive\" is true"
}

How to set up and validate locally

Verify response is unpaginated

  1. Create many files in a GDK repo and push the commit (e.g. via irb: 200.times {|i| system "touch #{i}" })
  2. Ensure that they are all returned with no pagination headers, e.g.: http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=true&pagination=none

Check various combinations of recursive and pagination params

Try the following example API calls (these are in Jetbrains HTTP client format):

### recursive=true with pagination=none (valid)
GET http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=true&pagination=none
Content-Type: application/json
PRIVATE-TOKEN: xxx

### recursive=false with pagination=none (invalid)
GET http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=false&pagination=none
Content-Type: application/json
PRIVATE-TOKEN: xxx

### recursive=true (valid)
GET http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=true
Content-Type: application/json
PRIVATE-TOKEN: xxx

### pagination=keyset (valid)
GET http://gdk.test:3000/api/v4/projects/1/repository/tree?pagination=keyset&per_page=2
Content-Type: application/json
PRIVATE-TOKEN: xxx

### recursive=true with pagination=keyset (valid)
GET http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=true&pagination=keyset&per_page=2
Content-Type: application/json
PRIVATE-TOKEN: xxx

### recursive=false with pagination=keyset (valid)
GET http://gdk.test:3000/api/v4/projects/1/repository/tree?recursive=false&pagination=keyset&per_page=2
Content-Type: application/json
PRIVATE-TOKEN: xxx

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Chad Woolley