You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* php-openapi/144-methods-naming-for-non-crud-actions:
Refactor
Remove TODO
Refactor and add docs
Add more concrete tests
Complete the test
Fix failing tests
Add fix & test for cebe#84
Add docs about URL rules config
Add docs
Add more tests
Fix bug
Fix style
Fix failing test
Fix bug - WIP
Fix this issue
Fix issue in generated url rule config
Fix issue: `actionCreateinvoicePayment` instead of `actionCreateInvoicePayment`
Initial commit to create this PR
Copy file name to clipboardExpand all lines: README.md
+75
Original file line number
Diff line number
Diff line change
@@ -317,6 +317,81 @@ Provide custom database table column name in case of relationship column. This w
317
317
- x-fk-column-name: redelivery_of # this will create `redelivery_of` column instead of `redelivery_of_id`
318
318
```
319
319
320
+
### `x-route`
321
+
322
+
To customize route (controller ID/action ID) for a path, use custom key `x-route` with value `<controller ID>/<action ID>`. It can be used for non-crud paths. It must be used under HTTP method key but not
323
+
directly under the `paths` key of OpenAPI spec. Example:
324
+
325
+
```yaml
326
+
paths:
327
+
/payments/invoice/{invoice}:
328
+
parameters:
329
+
- name: invoice
330
+
in: path
331
+
description: lorem ipsum
332
+
required: true
333
+
schema:
334
+
type: integer
335
+
post:
336
+
x-route: 'payments/invoice'
337
+
summary: Pay Invoice
338
+
description: Pay for Invoice with given invoice number
339
+
requestBody:
340
+
description: Record new payment for an invoice
341
+
content:
342
+
application/json:
343
+
schema:
344
+
$ref: '#/components/schemas/Payments'
345
+
required: true
346
+
responses:
347
+
'200':
348
+
description: Successfully paid the invoice
349
+
content:
350
+
application/json:
351
+
schema:
352
+
$ref: '#/components/schemas/Success'
353
+
```
354
+
355
+
It won't generate `actionCreateInvoice` in `PaymentsController.php` file, but will generate `actionInvoice` instead in
356
+
same file.
357
+
358
+
Generated URL rules config for above is (in `urls.rest.php` or pertinent file):
Copy file name to clipboardExpand all lines: src/lib/CustomSpecAttr.php
+5
Original file line number
Diff line number
Diff line change
@@ -40,4 +40,9 @@ class CustomSpecAttr
40
40
* Foreign key column name. See README for usage docs
41
41
*/
42
42
publicconstFK_COLUMN_NAME = 'x-fk-column-name';
43
+
44
+
/**
45
+
* Custom route (controller ID/action ID) instead of auto-generated. See README for usage docs. https://github.com/cebe/yii2-openapi/issues/144
0 commit comments