Skip to content

feat: adds a name field to the server object #4469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
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
19 changes: 15 additions & 4 deletions src/oas.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ An object representing a Server.
| ---- | :----: | ---- |
| <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`}`. |
| <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. |
| <a name="server-name"></a>name | `string` | An optional unique string to refer to the host designated by the URL. |
| <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. |

This object MAY be extended with [Specification Extensions](#specification-extensions).
Expand All @@ -488,13 +489,15 @@ A single server would be described as:
```json
{
"url": "https://development.gigantic-server.com/v1",
"description": "Development server"
"description": "Development server",
"name": "dev"
}
```

```yaml
url: https://development.gigantic-server.com/v1
description: Development server
name: dev
```

The following shows how multiple servers can be described, for example, at the OpenAPI Object's [`servers`](#oas-servers):
Expand All @@ -504,15 +507,18 @@ The following shows how multiple servers can be described, for example, at the O
"servers": [
{
"url": "https://development.gigantic-server.com/v1",
"description": "Development server"
"description": "Development server",
"name": "dev"
},
{
"url": "https://staging.gigantic-server.com/v1",
"description": "Staging server"
"description": "Staging server",
"name": "staging"
},
{
"url": "https://api.gigantic-server.com/v1",
"description": "Production server"
"description": "Production server",
"name": "prod"
}
]
}
Expand All @@ -522,10 +528,13 @@ The following shows how multiple servers can be described, for example, at the O
servers:
- url: https://development.gigantic-server.com/v1
description: Development server
name: dev
- url: https://staging.gigantic-server.com/v1
description: Staging server
name: staging
- url: https://api.gigantic-server.com/v1
description: Production server
name: prod
```

The following shows how variables can be used for a server configuration:
Expand All @@ -536,6 +545,7 @@ The following shows how variables can be used for a server configuration:
{
"url": "https://{username}.gigantic-server.com:{port}/{basePath}",
"description": "The production API server",
"name": "prod",
"variables": {
"username": {
"default": "demo",
Expand All @@ -558,6 +568,7 @@ The following shows how variables can be used for a server configuration:
servers:
- url: https://{username}.gigantic-server.com:{port}/{basePath}
description: The production API server
name: prod
variables:
username:
# note! no enum here means it is an open value
Expand Down
2 changes: 2 additions & 0 deletions src/schemas/validation/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ $defs:
type: string
description:
type: string
name:
type: string
variables:
type: object
additionalProperties:
Expand Down
1 change: 1 addition & 0 deletions tests/schema/pass/servers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ paths: {}
servers:
- url: /v1
description: Run locally.
name: local
- url: https://production.com/v1
description: Run on production server.