|
13 | 13 | use Dot\Maker\IO\Output; |
14 | 14 |
|
15 | 15 | use function implode; |
| 16 | +use function lcfirst; |
| 17 | +use function preg_replace; |
16 | 18 | use function sprintf; |
17 | 19 |
|
18 | 20 | use const PHP_EOL; |
@@ -84,6 +86,7 @@ public function render( |
84 | 86 | */ |
85 | 87 | #[OA\Delete( |
86 | 88 | path: '/{$entity->toKebabCase()}/{id}', |
| 89 | + operationId: '{$this->operationId($apiDeleteResourceHandler)}', |
87 | 90 | description: 'Authenticated (super)admin deletes resource of type {$entity->getClassName()}, identified by its ID', |
88 | 91 | summary: 'Admin deletes a resource of type {$entity->getClassName()}', |
89 | 92 | security: [['AuthToken' => []]], |
@@ -122,6 +125,7 @@ public function render( |
122 | 125 | */ |
123 | 126 | #[OA\Get( |
124 | 127 | path: '/{$entity->toKebabCase()}/{id}', |
| 128 | + operationId: '{$this->operationId($apiGetResourceHandler)}', |
125 | 129 | description: 'Authenticated (super)admin fetches a resource of type {$entity->getClassName()}, identified by its ID', |
126 | 130 | summary: 'Admin fetches a resource of type {$entity->getClassName()}', |
127 | 131 | security: [['AuthToken' => []]], |
@@ -163,6 +167,7 @@ public function render( |
163 | 167 | */ |
164 | 168 | #[OA\Get( |
165 | 169 | path: '/{$entity->toKebabCase()}', |
| 170 | + operationId: '{$this->operationId($apiGetCollectionHandler)}', |
166 | 171 | description: 'Authenticated (super)admin fetches a list of {$entity->toPlural()}', |
167 | 172 | summary: 'Admin lists {$entity->toPlural()}', |
168 | 173 | security: [['AuthToken' => []]], |
@@ -238,6 +243,7 @@ public function render( |
238 | 243 | */ |
239 | 244 | #[OA\Patch( |
240 | 245 | path: '/{$entity->toKebabCase()}/{id}', |
| 246 | + operationId: '{$this->operationId($apiPatchResourceHandler)}', |
241 | 247 | description: 'Authenticated (super)admin updates an existing {$entity->getClassName()}', |
242 | 248 | summary: 'Admin updates an existing {$entity->getClassName()}', |
243 | 249 | security: [['AuthToken' => []]], |
@@ -296,6 +302,7 @@ public function render( |
296 | 302 | */ |
297 | 303 | #[OA\Post( |
298 | 304 | path: '/{$entity->toKebabCase()}', |
| 305 | + operationId: '{$this->operationId($apiPostResourceHandler)}', |
299 | 306 | description: 'Authenticated (super)admin creates a new {$entity->getClassName()}', |
300 | 307 | summary: 'Admin creates a new {$entity->getClassName()}', |
301 | 308 | security: [['AuthToken' => []]], |
@@ -346,6 +353,7 @@ public function render( |
346 | 353 | */ |
347 | 354 | #[OA\Put( |
348 | 355 | path: '/{$entity->toKebabCase()}/{id}', |
| 356 | + operationId: '{$this->operationId($apiPutResourceHandler)}', |
349 | 357 | description: 'Authenticated (super)admin replaces an existing {$entity->getClassName()}', |
350 | 358 | summary: 'Admin updates an existing {$entity->getClassName()}', |
351 | 359 | security: [['AuthToken' => []]], |
@@ -460,4 +468,9 @@ public function render( |
460 | 468 |
|
461 | 469 | return $class->render(); |
462 | 470 | } |
| 471 | + |
| 472 | + private function operationId(File $handler): string |
| 473 | + { |
| 474 | + return lcfirst((string) preg_replace('/Handler$/', '', $handler->getComponent()->getClassName())); |
| 475 | + } |
463 | 476 | } |
0 commit comments