spectral:oas warn on by default

oas3_2-no-deprecated-xml-attribute

Applies to
xml
Selects
$..[?(@ && @.xml)].xml
Function
schema
Specs
OpenAPI 3.2
Message
"xml.attribute" is deprecated in OAS 3.2; use "xml.nodeType: attribute" instead.

Use it

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

extends: spectral:oas
rules:
  oas3_2-no-deprecated-xml-attribute: warn   # or off, or another severity

Definition

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

oas3_2-no-deprecated-xml-attribute:
  message: >-
    "xml.attribute" is deprecated in OAS 3.2; use "xml.nodeType: attribute"
    instead.
  recommended: true
  formats:
    - OpenAPI 3.2.x
  given:
    - '$..[?(@ && @.xml)].xml'
  then:
    function: schema
    functionOptions:
      schema:
        not:
          properties:
            attribute:
              const: true
          required:
            - attribute

About this rule

The xml.attribute field is deprecated in OpenAPI v3.2. Use xml.nodeType: attribute instead.

Only xml.attribute: true is flagged. xml.attribute: false is not flagged, since it matches the default nodeType behavior and has no corresponding migration action.

Bad Example

components:
  schemas:
    Pet:
      properties:
        name:
          type: string
          xml:
            attribute: true

Good Example

components:
  schemas:
    Pet:
      properties:
        name:
          type: string
          xml:
            nodeType: attribute

Sources