Skip to content

Commit e709bde

Browse files
committed
docs: adds an example for the action templates
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
1 parent d2748b4 commit e709bde

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

versions/1.2.0-dev.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,102 @@ paths:
635635
description: OK
636636
```
637637

638+
##### Action Template Example
639+
640+
###### Source Description
641+
642+
```yaml
643+
openapi: 3.2.0
644+
info:
645+
title: Example API
646+
version: 1.0.0
647+
paths:
648+
/items:
649+
get:
650+
responses:
651+
200:
652+
description: OK
653+
/some-items:
654+
delete:
655+
responses:
656+
200:
657+
description: OK
658+
```
659+
660+
###### Overlay
661+
662+
```yaml
663+
overlay: 1.2.0
664+
info:
665+
title: Use templates to insert error responses
666+
version: 1.0.0
667+
components:
668+
actionTemplates:
669+
errorResponse:
670+
target: "$.paths['%param.pathItem%'].%param.operation%.responses"
671+
update:
672+
404:
673+
description: Not Found
674+
application/json:
675+
schema:
676+
type: object
677+
properties:
678+
'%param.propertyName%':
679+
type: string
680+
description: Adds an error response to the %param.pathItem% path item %param.operation% operation
681+
parameters:
682+
- name: pathItem
683+
- name: operation
684+
default: get
685+
- name: propertyName
686+
default: errorMessage
687+
actions:
688+
- $ref: '#/components/actionTemplates/errorResponse'
689+
parameterValues:
690+
pathItem: '/items'
691+
- $ref: '#/components/actionTemplates/errorResponse'
692+
parameterValues:
693+
pathItem: '/some-items'
694+
operation: delete
695+
propertyName: deleteErrorMessage
696+
```
697+
698+
###### Result description
699+
700+
```yaml
701+
openapi: 3.2.0
702+
info:
703+
title: Example API
704+
version: 1.0.0
705+
paths:
706+
/items:
707+
get:
708+
responses:
709+
200:
710+
description: OK
711+
404:
712+
description: Not Found
713+
application/json:
714+
schema:
715+
type: object
716+
properties:
717+
errorMessage:
718+
type: string
719+
/some-items:
720+
delete:
721+
responses:
722+
200:
723+
description: OK
724+
404:
725+
description: Not Found
726+
application/json:
727+
schema:
728+
type: object
729+
properties:
730+
deleteErrorMessage:
731+
type: string
732+
```
733+
638734
### Specification Extensions
639735

640736
While the Overlay Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points.

0 commit comments

Comments
 (0)