Skip to content

Commit

Permalink
fix(parameters): Support int numerals and min-max lists
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Dec 21, 2023
1 parent 3321035 commit d157214
Show file tree
Hide file tree
Showing 3 changed files with 396 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@
['name' => 'Settings#defaultAndAdminScope', 'url' => '/api/{apiVersion}/default-and-admin-scope', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#nestedSchemas', 'url' => '/api/{apiVersion}/nested-schemas', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#listSchemas', 'url' => '/api/{apiVersion}/list-schemas', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#listOfIntParameters', 'url' => '/api/{apiVersion}/list-of-int', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#intParameterWithMinAndMax', 'url' => '/api/{apiVersion}/min-max', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#intParameterWithMin', 'url' => '/api/{apiVersion}/min', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
['name' => 'Settings#intParameterWithMax', 'url' => '/api/{apiVersion}/max', 'verb' => 'POST', 'requirements' => ['apiVersion' => '(v2)']],
],
];
48 changes: 48 additions & 0 deletions tests/lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,52 @@ public function nestedSchemas(): DataResponse {
public function listSchemas(): DataResponse {
return new DataResponse();
}

/**
* A route with a limited set of possible integers
*
* @param 1|2|3|4|5|6|7|8|9|10 $limit Maximum number of objects
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: Admin settings updated
*/
public function listOfIntParameters(int $limit): DataResponse {
return new DataResponse();
}

/**
* A route with a min and max integers
*
* @param int<5, 10> $limit Between 5 and 10
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: Admin settings updated
*/
public function intParameterWithMinAndMax(int $limit): DataResponse {
return new DataResponse();
}

/**
* A route with a min integers
*
* @param int<5, max> $limit At least 5
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: Admin settings updated
*/
public function intParameterWithMin(int $limit): DataResponse {
return new DataResponse();
}

/**
* A route with a max integers
*
* @param int<min, 10> $limit At most 10
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: Admin settings updated
*/
public function intParameterWithMax(int $limit): DataResponse {
return new DataResponse();
}
}
Loading

0 comments on commit d157214

Please sign in to comment.