# server-urls-no-trailing-slash

Source: https://api-genie.dev/docs/linter/openapi/rules/server-urls-no-trailing-slash

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. Since 0.12.0. Fixed by `--fix`. In the rulesets: Recommended at warning, Strict at error, All at error.

This rule checks that no URL in the document's top-level `servers`, other than `/`, ends with a
slash.

## Rule details

Paths start with a slash, and a client builds a request URL by appending the path to the server
URL. A server URL that also ends with a slash gives `https://api.example.com/v1//pets`, which
some servers and proxies route differently from `/v1/pets`, or refuse.

The rule reports `Server URL ends with a slash` on each such server. A server URL that is only
`/` (the host the document is served from) is not reported. The `servers` of path items and
operations are not checked.

Turn the rule off only for a document you can't change: a path starts with a slash, so a server
URL never needs one at its end.

## Examples

**Good**.

```yaml
servers:
  - url: https://api.example.com/v1
```

**Bad**.

```yaml
servers:
  - url: https://api.example.com/v1/
```

## Automatic fixes

`--fix` removes the trailing slashes. When `server-urls` also fixes the same URL, one `--fix` makes
one of the two changes, and the next makes the other.
