Skip to content

Commit bbb5d33

Browse files
committed
clarifications, respond to feedback
1 parent 9d93b09 commit bbb5d33

File tree

1 file changed

+57
-6
lines changed

1 file changed

+57
-6
lines changed

versions/3.0.md

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,8 @@ href | url | a relative or absolute URL to a linked resource. This field
11511151
parameters | Link Parameters Object | an Object representing parameters to pass to an operation as specified with `operationId` or identified via `href`.
11521152
description | string | a description of the link, supports GFM.
11531153

1154+
Locating a linked resource may be performed by either a `href` or `operationId`. In the case of an `operationId`, it must be unique and resolved in the scope of the OAS document. Because of the potential for name clashes, consider the `href` syntax as the preferred method for specifications with external references.
1155+
11541156
#### <a name="responsePayload"></a>Response Payload Values
11551157

11561158
Payload values are only available in parseable response payloads which match the advertised media-type. In all cases, if a value does _not_ exist, the parameter will be considered a `null` value (as opposed to an empty value) and _not_ passed as a parameter to the linked resource. In cases where a value is required, and a parameter is not supplied, the client _may_ choose to not follow the link definition.
@@ -1194,17 +1196,66 @@ The variables generated can be used in locations prescribed by the definition.
11941196

11951197

11961198
### Variable substitution
1197-
In all cases, _variables_ identified in the response payload may be substitued **only** in locations prescribed in the link definitions. All such locations are prefixed by a `$response` keyword and surrounded by curly brackets `{}`.
1199+
In all cases, _variables_ from request and responses may be substituted for link generation. The table below designates the source of the substitution value and the syntax for accessing it:
11981200

1199-
### Example
1200-
Computing a link from a response object is performed as follows:
1201+
Source Location | reference identifier | example value | example reference | notes
1202+
---|:---|:---|:---
1203+
HTTP Method | `$method` | `/users/{$method}` | The allowable values for the `$method` will be those for the HTTP operation
1204+
Requested content type | `$accepts` | `/users/3?format={$accepts}` |
1205+
Request parameter | `$request` | `/users/{$request.id}` | Request parameters must be declared in the `parameters` section for the operation or they cannot be used in substitution. This includes request headers
1206+
Request body | `$requestBody` | `/users/{$requestBody.user.uuid}` | For operations which accept payloads, references may be made to portions of the `requestBody` or the entire body itself
1207+
Request URL | `$url` | `/track?url={$url}` |
1208+
Response value | `$response` | `{$response.uuid}` | Only the payload in the response can be accessed with the `$response` syntax
1209+
Response header | `$responseHeader` | `{$responseHeader.Server}` | Single header values only are available.
1210+
1211+
From the request, the `parameter`s used in calling the operation are made available through the `$request` syntax. For responses, the response payload may be used with the `$response` syntax. For both requests and responses, values will be substituted in the link in sections designated with the `$request` or `$response` keyword, surrounded by curly brackets `{}`.
1212+
1213+
### Request parameter example
1214+
Computing a link from a request operation like such:
1215+
1216+
```yaml
1217+
paths:
1218+
/users/{id}:
1219+
parameters:
1220+
- name: id
1221+
in: path
1222+
required: true
1223+
description: the user identifier, as userId or username
1224+
schema:
1225+
type: string
1226+
responses:
1227+
200:
1228+
description: the user being returned
1229+
schema:
1230+
type: object
1231+
properties:
1232+
uuid: the unique user id
1233+
type: string
1234+
format: uuid
1235+
```
1236+
1237+
Can be used in a link like this:
12011238

12021239
```yaml
12031240
Addresses:
1204-
href: /users/{$response.id}/address
1241+
href: '/users/{$request.id}/department'
1242+
```
1243+
1244+
Where the `$request.id` is the value passed in the request to `/users/{id}`. For a `id` value of `10101110`, the generated link would be:
1245+
1246+
```yaml
1247+
href: '/users/10101110/department'
12051248
```
12061249

1207-
Where the `$response.id` from the example above would yield the target:
1250+
### Response payload example
1251+
1252+
```yaml
1253+
Addresses:
1254+
href: '/users/{$response.uuid}/address'
1255+
```
1256+
1257+
Where the `$response.uuid` from the example above would yield the target:
1258+
12081259

12091260
```yaml
12101261
href: '/users/df71a505-07bc-458a-a5c0-73c0340d1ec7/address'
@@ -1225,7 +1276,7 @@ href: 'http://colors.my-server.com/colors/green'
12251276
href: 'http://colors.my-server.com/colors/blue'
12261277
```
12271278

1228-
As with all links, it at the the clients' discretion to follow them, and permissions and the existence of a value is not guaranteed soley by the existence of a link relationship. [**I assume you mean that the existance of the link relationship does not guarantee a successful response from the call**]
1279+
As with all links, it at the the clients' discretion to follow them, and permissions and the ability to make a successful call to that link is not guaranteed soley by the existance of a relationship.
12291280

12301281

12311282
### Example

0 commit comments

Comments
 (0)