spectral:oas warn on by default

oas2-oneOf

oneOf is not available in OpenAPI v2, it was added in OpenAPI v3

Applies to
oneOf
Selects
$..oneOf
Function
undefined
Specs
OpenAPI 2.0
Message
"oneOf" keyword must not be used in OpenAPI v2 document.

Use it

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

extends: spectral:oas
rules:
  oas2-oneOf: warn   # or off, or another severity

Definition

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

oas2-oneOf:
  description: 'oneOf is not available in OpenAPI v2, it was added in OpenAPI v3'
  message: '"oneOf" keyword must not be used in OpenAPI v2 document.'
  recommended: true
  formats:
    - OpenAPI 2.0 (Swagger)
  given: $..oneOf
  then:
    function: undefined

About this rule

OpenAPI v3 keyword oneOf detected in OpenAPI v2 document.

Sources