western-digital · API Governance Rules

western-digital API Rules

Spectral linting rules defining API design standards and conventions for western-digital.

7 Rules error 1 warn 6
View Rules File View on GitHub

Rule Categories

wd

Rules

warn
wd-operation-id-kebab-case
Operation IDs must use camelCase.
$.paths.*.*.operationId
warn
wd-path-version-prefix
All paths should include a version prefix (e.g. /v1/, /v2/, /sdk/v2/).
$.paths[*]~
warn
wd-bearer-auth-required
All device-tier paths must declare bearerAuth security.
$.paths[?(!(/authorize|/oauth|/config))].*.security
warn
wd-response-200-content-type
Successful responses should return application/json.
$.paths.*.*.responses.200.content
error
wd-no-trailing-slash
Paths must not have a trailing slash.
$.paths[*]~
warn
wd-tags-defined
Each operation must include at least one tag.
$.paths.*.*.tags
warn
wd-description-required
Each operation must have a description.
$.paths.*.*.description

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  wd-operation-id-kebab-case:
    description: Operation IDs must use camelCase.
    message: "Operation ID '{{value}}' should use camelCase."
    severity: warn
    given: "$.paths.*.*.operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  wd-path-version-prefix:
    description: All paths should include a version prefix (e.g. /v1/, /v2/, /sdk/v2/).
    message: "Path '{{path}}' should include a version prefix (/v1/, /v2/, /sdk/v2/)."
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/(v[0-9]+|sdk/v[0-9]+|authservice/v[0-9]+|device/v[0-9]+|config/v[0-9]+)/"

  wd-bearer-auth-required:
    description: All device-tier paths must declare bearerAuth security.
    message: "Operation '{{path}}' must include bearerAuth security."
    severity: warn
    given: "$.paths[?(!(/authorize|/oauth|/config))].*.security"
    then:
      function: truthy

  wd-response-200-content-type:
    description: Successful responses should return application/json.
    message: "Response 200 at '{{path}}' should define application/json content."
    severity: warn
    given: "$.paths.*.*.responses.200.content"
    then:
      function: truthy

  wd-no-trailing-slash:
    description: Paths must not have a trailing slash.
    message: "Path '{{value}}' must not end with a trailing slash."
    severity: error
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  wd-tags-defined:
    description: Each operation must include at least one tag.
    message: "Operation at '{{path}}' must include at least one tag."
    severity: warn
    given: "$.paths.*.*.tags"
    then:
      function: truthy

  wd-description-required:
    description: Each operation must have a description.
    message: "Operation at '{{path}}' is missing a description."
    severity: warn
    given: "$.paths.*.*.description"
    then:
      function: truthy