spectral:oas warn on by default

oas3_1-servers-in-webhook

Applies to
servers
Selects
$.webhooks.servers
$.webhooks[*][*].servers
Function
undefined
Specs
OpenAPI 3.1OpenAPI 3.2
Message
Servers should not be defined in a webhook.

Use it

This rule ships with OpenLint in spectral:oas. Extending the ruleset turns it on:

extends: spectral:oas
rules:
  oas3_1-servers-in-webhook: warn   # or off, or another severity

Definition

As defined in @openlint/openlint-rulesets. Functions show by name.

oas3_1-servers-in-webhook:
  message: Servers should not be defined in a webhook.
  recommended: true
  formats:
    - OpenAPI 3.1.x
    - OpenAPI 3.2.x
  given:
    - $.webhooks.servers
    - '$.webhooks[*][*].servers'
  then:
    function: undefined

About this rule

Servers should not be defined in a webhook. Applies to OpenAPI v3.1 and v3.2.

Bad Example

At the path item object level:

webhooks:
  servers:
    - url: https://example.com/
    - url: https://example.com/api/

or

At the operation level:

webhooks:
  newPet:
    post:
      servers:
        -url: https://example.com/

Sources