1. Go to this page and download the library: Download wapmorgan/openapi-generator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
/**
* Returns lists of filters
* @param Request $request
* @return ListsResponse
*/
public function lists(Request $request) {
return new ListsResponse([
// 'persons' => range(1, 15),
'persons' => array_keys(Menu::$personsList),
'tastes' => Menu::$tastes,
'meat' => Menu::$meat,
'pizzas' => Menu::$pizzas,
]);
}
/**
* Makes a selection of pizzas according to criteria
* @param \App\Http\Requests\SelectPizzas $request
* @return PizzaListItem[]
*/
public function select(\App\Http\Requests\SelectPizzas $request) {
$validated = $request->validated();
return (new Selector())->select(
$validated['city'], $validated['persons'],
$validated['tastes'] ?? null, $validated['meat'] ?? null,
$validated['vegetarian'] ?? false, $validated['maxPrice'] ?? null);
}
class SelectPizzas extends FormRequest {
public function rules()
{
// ...
return array_merge([
'city' => ['c'],
'pizzas' => ['array', Rule::in(array_keys(Menu::$pizzas))],
], $tastes, $meat);
}
}
class ListsResponse extends BaseResponse {
/** @var string[] */
public $persons;
/** @var string[] */
public $tastes;
/** @var string[] */
public $meat;
/** @var string[] */
public $pizzas;
}
class PizzaListItem extends BaseResponse {
public string $pizzeria;
public string $id;
public int $sizeId;
public string $name;
public float $size;
public array $tastes;
public array $meat;
public float $price;
public float $pizzaArea;
public float $pizzaCmPrice;
public string $thumbnail;
public array $ingredients;
public int $dough;
}