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
Copy file name to clipboardExpand all lines: versions/3.0.md
+57-6Lines changed: 57 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1151,6 +1151,8 @@ href | url | a relative or absolute URL to a linked resource. This field
1151
1151
parameters | Link Parameters Object | an Object representing parameters to pass to an operation as specified with `operationId` or identified via `href`.
1152
1152
description | string | a description of the link, supports GFM.
1153
1153
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.
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.
1194
1196
1195
1197
1196
1198
### 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:
1198
1200
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:
1201
1238
1202
1239
```yaml
1203
1240
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'
1205
1248
```
1206
1249
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:
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.
0 commit comments