Skip to content

Commit 1a3ddd1

Browse files
authored
Merge pull request #4469 from baywet/feat/server-name
feat: adds a name field to the server object
2 parents bab4f12 + cc1be37 commit 1a3ddd1

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/oas.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ An object representing a Server.
477477
| ---- | :----: | ---- |
478478
| <a name="server-url"></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 document containing the Server Object is being served. Variable substitutions will be made when a variable is named in `{`braces`}`. |
479479
| <a name="server-description"></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. |
480+
| <a name="server-name"></a>name | `string` | An optional unique string to refer to the host designated by the URL. |
480481
| <a name="server-variables"></a>variables | Map[`string`, [Server Variable Object](#server-variable-object)] | A map between a variable name and its value. The value is used for substitution in the server's URL template. |
481482

482483
This object MAY be extended with [Specification Extensions](#specification-extensions).
@@ -488,13 +489,15 @@ A single server would be described as:
488489
```json
489490
{
490491
"url": "https://development.gigantic-server.com/v1",
491-
"description": "Development server"
492+
"description": "Development server",
493+
"name": "dev"
492494
}
493495
```
494496

495497
```yaml
496498
url: https://development.gigantic-server.com/v1
497499
description: Development server
500+
name: dev
498501
```
499502

500503
The following shows how multiple servers can be described, for example, at the OpenAPI Object's [`servers`](#oas-servers):
@@ -504,15 +507,18 @@ The following shows how multiple servers can be described, for example, at the O
504507
"servers": [
505508
{
506509
"url": "https://development.gigantic-server.com/v1",
507-
"description": "Development server"
510+
"description": "Development server",
511+
"name": "dev"
508512
},
509513
{
510514
"url": "https://staging.gigantic-server.com/v1",
511-
"description": "Staging server"
515+
"description": "Staging server",
516+
"name": "staging"
512517
},
513518
{
514519
"url": "https://api.gigantic-server.com/v1",
515-
"description": "Production server"
520+
"description": "Production server",
521+
"name": "prod"
516522
}
517523
]
518524
}
@@ -522,10 +528,13 @@ The following shows how multiple servers can be described, for example, at the O
522528
servers:
523529
- url: https://development.gigantic-server.com/v1
524530
description: Development server
531+
name: dev
525532
- url: https://staging.gigantic-server.com/v1
526533
description: Staging server
534+
name: staging
527535
- url: https://api.gigantic-server.com/v1
528536
description: Production server
537+
name: prod
529538
```
530539

531540
The following shows how variables can be used for a server configuration:
@@ -536,6 +545,7 @@ The following shows how variables can be used for a server configuration:
536545
{
537546
"url": "https://{username}.gigantic-server.com:{port}/{basePath}",
538547
"description": "The production API server",
548+
"name": "prod",
539549
"variables": {
540550
"username": {
541551
"default": "demo",
@@ -558,6 +568,7 @@ The following shows how variables can be used for a server configuration:
558568
servers:
559569
- url: https://{username}.gigantic-server.com:{port}/{basePath}
560570
description: The production API server
571+
name: prod
561572
variables:
562573
username:
563574
# note! no enum here means it is an open value

src/schemas/validation/schema.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ $defs:
121121
type: string
122122
description:
123123
type: string
124+
name:
125+
type: string
124126
variables:
125127
type: object
126128
additionalProperties:

tests/schema/pass/servers.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ paths: {}
66
servers:
77
- url: /v1
88
description: Run locally.
9+
name: local
910
- url: https://production.com/v1
1011
description: Run on production server.
1112
- url: https://{username}.gigantic-server.com:{port}/{basePath}

0 commit comments

Comments
 (0)