| Conditions | 6 |
| Paths | 4 |
| Total Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function getCollection() |
||
| 26 | { |
||
| 27 | $collection = [ |
||
| 28 | 'variables' => [], |
||
| 29 | 'info' => [ |
||
| 30 | 'name' => config('apidoc.postman.name') ?: config('app.name').' API', |
||
| 31 | '_postman_id' => Uuid::uuid4()->toString(), |
||
| 32 | 'description' => config('apidoc.postman.description') ?: '', |
||
| 33 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
||
| 34 | ], |
||
| 35 | 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
||
| 36 | return [ |
||
| 37 | 'name' => $groupName, |
||
| 38 | 'description' => '', |
||
| 39 | 'item' => $routes->map(function ($route) { |
||
| 40 | $mode = $route['methods'][0] === 'PUT' ? 'urlencoded' : 'formdata'; |
||
| 41 | |||
| 42 | return [ |
||
| 43 | 'name' => $route['title'] != '' ? $route['title'] : url($route['uri']), |
||
| 44 | 'request' => [ |
||
| 45 | 'url' => url($route['uri']), |
||
| 46 | 'method' => $route['methods'][0], |
||
| 47 | 'body' => [ |
||
| 48 | 'mode' => $mode, |
||
| 49 | $mode => collect($route['bodyParameters'])->map(function ($parameter, $key) { |
||
| 50 | return [ |
||
| 51 | 'key' => $key, |
||
| 52 | 'value' => isset($parameter['value']) ? $parameter['value'] : '', |
||
| 53 | 'type' => 'text', |
||
| 54 | 'enabled' => true, |
||
| 55 | ]; |
||
| 56 | })->values()->toArray(), |
||
| 57 | ], |
||
| 58 | 'description' => $route['description'], |
||
| 59 | 'response' => [], |
||
| 60 | ], |
||
| 61 | ]; |
||
| 62 | })->toArray(), |
||
| 63 | ]; |
||
| 64 | })->values()->toArray(), |
||
| 65 | ]; |
||
| 66 | |||
| 67 | return json_encode($collection); |
||
| 68 | } |
||
| 69 | } |
||
| 70 |