Skip to content

Commit 5633f57

Browse files
committed
feat: adds reusable actions to the components
Signed-off-by: Vincent Biret <vincentbiret@hotmail.com>
1 parent 77d9e4f commit 5633f57

1 file changed

Lines changed: 98 additions & 1 deletion

File tree

versions/1.2.0-dev.md

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ This is the root object of the [Overlay](#overlay).
8484
| <a name="overlay-version"></a>overlay | `string` | **REQUIRED**. This string MUST be the [version number](#versions) of the Overlay Specification that the Overlay document uses. The `overlay` field SHOULD be used by tooling to interpret the Overlay document. |
8585
| <a name="overlay-info"></a>info | [Info Object](#info-object) | **REQUIRED**. Provides metadata about the Overlay. The metadata MAY be used by tooling as required. |
8686
| <a name="overlay-extends"></a>extends | `string` | URI reference that identifies the target document (such as an [[OpenAPI]] document) this overlay applies to. |
87-
| <a name="overlay-actions"></a>actions | [[Action Object](#action-object) or [Action Template Reference Object](#action-template-reference-object)] | **REQUIRED** An ordered list of actions to be applied to the target document. The array MUST contain at least one value. |
87+
| <a name="overlay-actions"></a>actions | [[Action Object](#action-object) or [Action Template Reference Object](#action-template-reference-object) or [Action Reference Object](#action-reference-object)] | **REQUIRED** An ordered list of actions to be applied to the target document. The array MUST contain at least one value. |
8888
| <a name="overlay-components"></a>components | [Component Object](#component-object) | A set of components to reuse across the Overlay Document. Optional. |
8989

9090
This object MAY be extended with [Specification Extensions](#specification-extensions).
@@ -138,6 +138,9 @@ The object provides a set of components to be reused across the Overlay document
138138
| Field Name | Type | Description |
139139
| ---- | :----: | ---- |
140140
| <a name="component-action-templates"></a>actionTemplates | Map(`string`, [Action Template Object](#action-template-object)) | A key-value set of action templates to reference in the actions. Optional. |
141+
| <a name="component-actions"></a>actions | Map(`string`, [Action Object](#action-object) or [Action Template Reference Object](#action-template-reference-object)) | A key-value set of actions or action template references to use in the actions. Optional. |
142+
143+
> Note: the target field for components actions is Optional.
141144

142145
This object MAY be extended with [Specification Extensions](#specification-extensions).
143146

@@ -195,6 +198,15 @@ This object MAY be extended with [Specification Extensions](#specification-exten
195198

196199
This object MAY be extended with [Specification Extensions](#specification-extensions).
197200

201+
#### Action reference object
202+
203+
##### Fixed fields
204+
205+
| Field Name | Type | Description |
206+
| ---- | :----: | ---- |
207+
| <a name="action-reference-ref"></a>$ref | `string` | **REQUIRED** A valid reference to an action in the components section, represented as `#/components/actions/actionTemplateKey`. |
208+
| <a name="action-reference-target"></a>target | `string` | A RFC9535 JSONPath query expression selecting nodes in the target document and overrides the target defined in the referenced action. Optional when the resolved action defines a target, required when the resolved action does not. |
209+
198210
#### Action template reference object
199211

200212
##### Fixed fields
@@ -635,6 +647,91 @@ paths:
635647
description: OK
636648
```
637649

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

640737
###### Source Description

0 commit comments

Comments
 (0)