Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 280 additions & 1 deletion versions/1.2.0-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ This is the root object of the [Overlay](#overlay).
| <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. |
| <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. |
| <a name="overlay-extends"></a>extends | `string` | URI reference that identifies the target document (such as an [[OpenAPI]] document) this overlay applies to. |
| <a name="overlay-actions"></a>actions | [[Action Object](#action-object)] | **REQUIRED** An ordered list of actions to be applied to the target document. The array MUST contain at least one value. |
| <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. |
| <a name="overlay-components"></a>components | [Components Object](#components-object) | A set of components to reuse across the Overlay Document. Optional. |

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

Expand Down Expand Up @@ -128,6 +129,20 @@ The metadata MAY be used by the clients if needed.

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

#### Components Object

The object provides a set of components to be reused across the Overlay document.

##### Fixed Fields

| Field Name | Type | Description |
| ---- | :----: | ---- |
| <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. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| <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. |
| <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 action template instantiations. Optional. |


> Note: the target field for components actions is Optional.

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

#### Action Object

This object represents one or more changes to be applied to the target document at the locations defined by the target JSONPath expression.
Expand Down Expand Up @@ -157,6 +172,72 @@ The properties of the `update` or `copy` object MUST be compatible with the targ

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

#### Action Template Object

This object represents one or more changes to be applied to the target document at the locations defined by the target JSONPath expression and reused in one of more action references.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This object represents one or more changes to be applied to the target document at the locations defined by the target JSONPath expression and reused in one of more action references.
This object is a template that, when instantiated by an Action Template Instantiation, represents one or more changes to be applied to the target document at the locations defined by the target JSONPath expression and reused in one of more action references.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An action template is similar to an action, but differs in two important ways:
1. It may omit any action field, in particular the `target` field, as these may be supplied by the Action Template Instantiation.
2. Any action field may employ string interpolation using variables specified in the `parameters` or `environmentVariables` fields.

##### Fixed fields

| Field Name | Type | Description |
| ---- | :----: | ---- |
| <a name="action-template-parameters"></a>parameters | [[Action template parameter object](#action-template-parameter-object)] | A list of parameters to be used during string literal replacement. Optional. |
| <a name="action-template-environment-variables"></a>environmentVariables | [[Action template parameter object](#action-template-parameter-object)] | A list of environment variables to be used during string literal replacement. Optional. |
| <a name="action-template-action-fields"></a>Any field defined in the [action object](#action-object) | mixed | The [string literal replacement syntax](#string-literal-replacement-syntax) MAY be used for any of the fields, and the replacements MUST be evaluated as the template reference is being resolved. |

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

#### Action Template Parameter Object

##### Fixed fields

| Field Name | Type | Description |
| ---- | :----: | ---- |
| <a name="action-template-parameter-name"></a>name | `string` | **REQUIRED** The name of the parameter, MUST match the key for the string literal replacement expression. |
| <a name="action-template-parameter-default>default | Any | A default value for the parameter to use when no value is provided by the reference. Optional. |


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


#### Action Template Reference Object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling this a "Reference Object" is confusing and inconsistent with other uses of this terminology. I suggest calling this an "Action Template Instantiation Object", as it's primary function is to "instantiate" a template.


##### Fixed fields

| Field Name | Type | Description |
| ---- | :----: | ---- |
| <a name="action-template-reference-ref"></a>$ref | `string` | **REQUIRED** A [same-document](https://www.rfc-editor.org/rfc/rfc3986.html#section-4.4) (or fragment-only) relative URI reference, per RFC3986 §4.4, and that the fragment syntax is JSON Pointer, with the pointer prefix restricted to `/components/actionTemplates/`. |
| <a name="action-template-reference-parameter-values></a>parameterValues | `Map(string, Any)` | A set of values to use for the template parameters, the key MUST match the parameter name. Optional. |
| <a name="action-template-reference-action-fields"></a>Any field defined in the [action object](#action-object) | mixed | Any field defined in the [Action Object](#action-object) to be used as an override to the value resolved in the template. The [string literal replacement syntax](#string-literal-replacement-syntax) MAY NOT be used for any of the fields. Optional. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could eliminate the action fields here. They are already allowed in the template, so the action field in the template could be defined with a parameterize value, and the field value can then be passed in a parameter value. So eliminating the action fields here loses no functionality.


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

### String Literal Replacement Syntax

The following string replacement syntax MAY be used:

%source.key%

Where **source** is a known source whose value MUST ONLY be **env** for environment variables, or **param** for parameters. The key MUST only contain the following characters A-Za-z0-9, contain at least one character and start with a letter.

#### ABNF Notation

```abnf
replacement-string = "%" source "." key "%"
source = "env" / "param"
key = ALPHA *( ALPHA / DIGIT )
```

Where ALPHA and DIGIT rules are defined in [[RFC5234]].

#### Environment Replacement Source

When the environment replacement source is used, the key MUST match (case-sensitive) an environment variable defined for the process parsing the Overlay document. If the environment variable is not defined, the processor MAY either replace it with an empty string or return an error.

#### Parameter Replacement Source

When the parameter replacement source is used, the key MUST match (case-sensitive) a corresponding parameter defined for the action template.


### Examples

#### Structured Overlay Example
Expand Down Expand Up @@ -559,6 +640,204 @@ paths:
description: OK
```

##### Action Template Reference Example - Overrides

###### Source Description

```yaml
openapi: 3.2.0
info:
title: Example API
version: 1.0.0
paths:
/items:
get:
responses:
200:
description: OK
/some-items:
delete:
responses:
200:
description: OK
```

###### Overlay

```yaml
overlay: 1.2.0
info:
title: Use templates to insert error responses
version: 1.0.0
components:
actionTemplates:
errorResponse:
update:
404:
description: Not Found
application/json:
schema:
type: object
properties:
message:
type: string
target: "$.paths['placeholder'].get.response"
description: Adds an error response to the %param.pathItem% path item %param.operation% operation
actions:
- $ref: '#/components/actions/errorResponse'
# the target from the action template is being superseded by this local override value
target: "$.paths['items'].get.responses"
- $ref: '#/components/actions/errorResponse'
# the target from the action template is being superseded by this local override value
target: "$.paths['some-items'].delete.responses"
```

###### Result Description

```yaml
openapi: 3.2.0
info:
title: Example API
version: 1.0.0
paths:
/items:
get:
responses:
200:
description: OK
404:
description: Not Found
application/json:
schema:
type: object
properties:
errorMessage:
type: string
/some-items:
delete:
responses:
200:
description: OK
404:
description: Not Found
application/json:
schema:
type: object
properties:
deleteErrorMessage:
type: string
```

##### Action Template Example - Parameters

###### Source Description

```yaml
openapi: 3.2.0
info:
title: Example API
version: 1.0.0
paths:
/items:
get:
responses:
200:
description: OK
/some-items:
delete:
responses:
200:
description: OK
```

###### Overlay

```yaml
overlay: 1.2.0
info:
title: Use templates to insert error responses
version: 1.0.0
components:
actionTemplates:
errorResponse:
target: "$.paths['%param.pathItem%'].%param.operation%.responses"
update:
404:
description: Not Found
application/json:
schema:
type: object
properties:
'%param.propertyName%':
type: string
stageName:
type: string
const: '%env.stageName%'
description: Adds an error response to the %param.pathItem% path item %param.operation% operation
parameters:
- name: pathItem
- name: operation
default: get
- name: propertyName
default: errorMessage
environmentVariables:
- name: stageName
default: dev
actions:
- $ref: '#/components/actionTemplates/errorResponse'
parameterValues:
pathItem: '/items'
- $ref: '#/components/actionTemplates/errorResponse'
parameterValues:
pathItem: '/some-items'
operation: delete
propertyName: deleteErrorMessage
```

> Note: in this example, no value is set for the process environment variable "stageName".

###### Result Description

```yaml
openapi: 3.2.0
info:
title: Example API
version: 1.0.0
paths:
/items:
get:
responses:
200:
description: OK
404:
description: Not Found
application/json:
schema:
type: object
properties:
errorMessage:
type: string
stageName:
type: string
const: dev
/some-items:
delete:
responses:
200:
description: OK
404:
description: Not Found
application/json:
schema:
type: object
properties:
deleteErrorMessage:
type: string
stageName:
type: string
const: dev
```

### Specification Extensions

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