Skip to content

Commit 31a1214

Browse files
committed
Fixes OAI#1675. Clarifies the language around server variables to make it clear that the API consumer, not the server, and not an unpecified poltergeist, is responsible for variable interpolation in all cases. The default value of a server variable is to by handled by the consumer (a.k.a. client), who will substitute that value into the URL template unless the client has a some alternative value assigned by user input, configuration, hard-coding, or whatever.
1 parent d2cd322 commit 31a1214

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

versions/3.0.3.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,15 @@ url: https://www.apache.org/licenses/LICENSE-2.0.html
317317

318318
#### <a name="serverObject"></a>Server Object
319319

320-
An object representing a Server.
320+
An object representing a single server or a group of servers sharing a common URL structure.
321321

322322
##### Fixed Fields
323323

324324
Field Name | Type | Description
325325
---|:---:|---
326-
<a name="serverUrl"></a>url | `string` | **REQUIRED**. A URL to the target host. This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served. Variable substitutions will be made when a variable is named in `{`brackets`}`.
326+
<a name="serverUrl"></a>url | `string` | **REQUIRED**. A URL to the target host. This URL may include variable expressions, delimited by `{`curly braces`}`. Each variable expression MUST correspond to a [Server Variable Object](#serverVariableObject) named in the `variables` field, and the API consumer MUST replace each variable expression with a with a valid value, as specified by the corresponding Server Variable Object. The URL MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served.
327327
<a name="serverDescription"></a>description | `string` | An optional string describing the host designated by the URL. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
328-
<a name="serverVariables"></a>variables | Map[`string`, [Server Variable Object](#serverVariableObject)] | A map between a variable name and its value. The value is used for substitution in the server's URL template.
328+
<a name="serverVariables"></a>variables | Map[`string`, [Server Variable Object](#serverVariableObject)] | A map between a server variable name and a Server Variable Object. Each server variable name SHOULD be referenced by a variable expression in the `url`.
329329

330330
This object MAY be extended with [Specification Extensions](#specificationExtensions).
331331

@@ -387,7 +387,7 @@ The following shows how variables can be used for a server configuration:
387387
"variables": {
388388
"username": {
389389
"default": "demo",
390-
"description": "this value is assigned by the service provider, in this example `gigantic-server.com`"
390+
"description": "A user-specific subdomain provisioned for each account. Use `demo` for a free sandbox environment."
391391
},
392392
"port": {
393393
"enum": [
@@ -413,7 +413,9 @@ servers:
413413
username:
414414
# note! no enum here means it is an open value
415415
default: demo
416-
description: this value is assigned by the service provider, in this example `gigantic-server.com`
416+
description: |
417+
A user-specific subdomain provisioned for each account.
418+
Use `demo` for a free sandbox environment.
417419
port:
418420
enum:
419421
- '8443'
@@ -427,14 +429,16 @@ servers:
427429
428430
#### <a name="serverVariableObject"></a>Server Variable Object
429431
430-
An object representing a Server Variable for server URL template substitution.
432+
An object representing a Server Variable for URL template substitution in a containing [Server Object](#serverObject).
433+
434+
To form an addressable server URL, the API consumer MUST substitute a valid value for each variable expression in the Server Object's `url` template. The API consumer MAY assign Server Variable values from user input, configuration settings, or any other source. If the API consumer does not have an assigned value for a given server variable, it MUST substitute the provided `default` value.
431435

432436
##### Fixed Fields
433437

434438
Field Name | Type | Description
435439
---|:---:|---
436-
<a name="serverVariableEnum"></a>enum | [`string`] | An enumeration of string values to be used if the substitution options are from a limited set. The array SHOULD NOT be empty.
437-
<a name="serverVariableDefault"></a>default | `string` | **REQUIRED**. The default value to use for substitution, which SHALL be sent if an alternate value is _not_ supplied. Note this behavior is different than the [Schema Object's](#schemaObject) treatment of default values, because in those cases parameter values are optional. If the [`enum`](#serverVariableEnum) is defined, the value SHOULD exist in the enum's values.
440+
<a name="serverVariableEnum"></a>enum | [`string`] | An enumeration of valid string values for this variable. The array SHOULD NOT be empty. If `enum` is specified, the API consumer MUST assign one of enumerated values to the server variable.
441+
<a name="serverVariableDefault"></a>default | `string` | **REQUIRED**. The default value for the server variable. If [`enum`](#serverVariableEnum) is defined, the `default` value SHOULD exist in the enum's values. If the API consumer does not have an alternative value, it MUST substitute the `default` value. Note that this behavior is different from the [Schema Object's](#schemaObject) treatment of default values. Schema defaults can be resolved by the server, and MAY be omitted from the request; but Server Variables MUST be resolved to an assigned or default value by the client, to assemble a final URL for the API request.
438442
<a name="serverVariableDescription"></a>description | `string` | An optional description for the server variable. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
439443

440444
This object MAY be extended with [Specification Extensions](#specificationExtensions).

0 commit comments

Comments
 (0)