Xiaomi · API Governance Rules

Xiaomi API Rules

Spectral linting rules defining API design standards and conventions for Xiaomi.

8 Rules warn 5 info 3
View Rules File View on GitHub

Rule Categories

xiaomi

Rules

warn
xiaomi-operation-summary-title-case
All operation summaries must use Title Case.
$.paths[*][*].summary
warn
xiaomi-operation-id-camel-case
All operationIds must use camelCase.
$.paths[*][*].operationId
warn
xiaomi-tags-required
All operations must have at least one tag.
$.paths[*][*]
warn
xiaomi-response-200-required
All operations must define a 200 or 201 response.
$.paths[*][*].responses
info
xiaomi-security-defined
All operations must define security requirements.
$.paths[*][*]
warn
xiaomi-description-required
All operations must have a description.
$.paths[*][*].description
info
xiaomi-parameter-description
All parameters must have descriptions.
$.paths[*][*].parameters[*].description
info
xiaomi-api-version-prefix
API paths should be prefixed with a version segment like /v1/.
$.paths

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  xiaomi-operation-summary-title-case:
    description: All operation summaries must use Title Case.
    message: "Operation summary '{{value}}' must use Title Case."
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*([ ][A-Z][a-zA-Z0-9]*)*$"

  xiaomi-operation-id-camel-case:
    description: All operationIds must use camelCase.
    message: "OperationId '{{value}}' must use camelCase."
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  xiaomi-tags-required:
    description: All operations must have at least one tag.
    message: "Operation is missing tags."
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  xiaomi-response-200-required:
    description: All operations must define a 200 or 201 response.
    message: "Operation must define a success (200/201) response."
    severity: warn
    given: "$.paths[*][*].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['201']

  xiaomi-security-defined:
    description: All operations must define security requirements.
    message: "Operation should define security requirements."
    severity: info
    given: "$.paths[*][*]"
    then:
      field: security
      function: truthy

  xiaomi-description-required:
    description: All operations must have a description.
    message: "Operation is missing a description."
    severity: warn
    given: "$.paths[*][*].description"
    then:
      function: truthy

  xiaomi-parameter-description:
    description: All parameters must have descriptions.
    message: "Parameter '{{value}}' is missing a description."
    severity: info
    given: "$.paths[*][*].parameters[*].description"
    then:
      function: truthy

  xiaomi-api-version-prefix:
    description: API paths should be prefixed with a version segment like /v1/.
    message: "Path '{{property}}' should begin with a version prefix (e.g., /v1/)."
    severity: info
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^/v[0-9]+"