Warner Bros. Discovery · API Governance Rules

Warner Bros. Discovery API Rules

Spectral linting rules defining API design standards and conventions for Warner Bros. Discovery.

10 Rules error 6 warn 4
View Rules File View on GitHub

Rule Categories

wbd

Rules

error
wbd-operation-ids-required
All operations must have an operationId
$.paths[*][*]
warn
wbd-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
wbd-operation-tags-required
All operations must have at least one tag
$.paths[*][*]
error
wbd-paths-versioned
All API paths must include a version prefix (/v1/, /v2/, etc.)
$.paths
error
wbd-oauth2-security
WBD APIs use OAuth2 client credentials for authentication
$.components.securitySchemes
error
wbd-response-200-or-201
All operations must define a successful 2xx response
$.paths[*][*].responses
warn
wbd-error-responses-defined
Operations should define 401 and 404 error responses
$.paths[*][*].responses
error
wbd-info-description
Info object must have a description
$.info
warn
wbd-response-schema
Successful responses must define a schema
$.paths[*][*].responses['200'].content['application/json']
warn
wbd-pagination-parameters
Collection GET endpoints should support limit and offset parameters
$.paths[*].get.parameters[*].name

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  wbd-operation-ids-required:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  wbd-operation-summary-title-case:
    description: Operation summaries must use Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*(\\s[A-Z][a-zA-Z0-9]*)*$"

  wbd-operation-tags-required:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  wbd-paths-versioned:
    description: All API paths must include a version prefix (/v1/, /v2/, etc.)
    severity: error
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^\\/v[0-9]+"

  wbd-oauth2-security:
    description: WBD APIs use OAuth2 client credentials for authentication
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  wbd-response-200-or-201:
    description: All operations must define a successful 2xx response
    severity: error
    given: "$.paths[*][*].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["200"]
            - required: ["201"]
            - required: ["202"]

  wbd-error-responses-defined:
    description: Operations should define 401 and 404 error responses
    severity: warn
    given: "$.paths[*][*].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - "401"

  wbd-info-description:
    description: Info object must have a description
    severity: error
    given: "$.info"
    then:
      field: description
      function: truthy

  wbd-response-schema:
    description: Successful responses must define a schema
    severity: warn
    given: "$.paths[*][*].responses['200'].content['application/json']"
    then:
      field: schema
      function: truthy

  wbd-pagination-parameters:
    description: Collection GET endpoints should support limit and offset parameters
    severity: warn
    given: "$.paths[*].get.parameters[*].name"
    then:
      function: enumeration
      functionOptions:
        values:
          - limit
          - offset
          - page
          - pageSize
          - cursor