Skip to content
Last updated

spec-no-invalid-xml-combinations

Ensures that XML objects do not use the nodeType field together with the deprecated attribute or wrapped field.

OASCompatibility
2.0❌
3.0❌
3.1❌
3.2✅

Root

Components

Schema

Xml

Root

Components

Schema

Xml

API design principles

OpenAPI 3.2 adds the nodeType field to the XML Object and deprecates the attribute and wrapped fields. The specification does not allow a deprecated field in an XML object that has nodeType, because the two can contradict each other.

This rule reports the following combinations:

  • An XML object with both nodeType and attribute. Remove attribute, because nodeType replaces it: nodeType: attribute in place of attribute: true.
  • An XML object with both nodeType and wrapped. Remove wrapped, because nodeType replaces it: nodeType: element in place of wrapped: true.

Configuration

OptionTypeDescription
severitystringPossible values: off, warn, error. Default error (in recommended configuration).

An example configuration:

rules:
  spec-no-invalid-xml-combinations: error

Examples

Given this configuration:

rules:
  spec-no-invalid-xml-combinations: error

Example of incorrect XML objects:

components:
  schemas:
    MenuItem:
      type: object
      properties:
        id:
          type: string
          xml:
            attribute: true
            nodeType: attribute
        tags:
          type: array
          xml:
            wrapped: true
            nodeType: element
          items:
            type: string

Example of correct XML objects:

components:
  schemas:
    MenuItem:
      type: object
      properties:
        id:
          type: string
          xml:
            nodeType: attribute
        tags:
          type: array
          xml:
            nodeType: element
          items:
            type: string

Resources