Tivo · API Governance Rules

Tivo API Rules

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

13 Rules error 6 warn 5
View Rules File View on GitHub

Rule Categories

tivo

Rules

error
tivo-operation-ids-required
All operations must have operationId values
$.paths[*][get,post,put,delete,patch]
error
tivo-operation-summaries-required
All operations must have a summary
$.paths[*][get,post,put,delete,patch]
warn
tivo-operation-tags-required
All operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
error
tivo-versioned-paths
All paths must begin with /v3/ for the Video Metadata API
$.paths
error
tivo-bearer-auth-required
API must define bearer token authentication
$.components.securitySchemes.bearerAuth
error
tivo-response-200-defined
All GET operations must define a 200 success response
$.paths[*].get
warn
tivo-response-401-defined
All operations must handle unauthorized responses
$.paths[*][get,post]
warn
tivo-response-404-defined
Resource lookup operations must handle not found responses
$.paths[*~contains('{')][get]
warn
tivo-kebab-case-paths
Path segments must use kebab-case
$.paths
warn
tivo-content-type-json
Response schemas must use application/json content type
$.paths[*][*].responses[*].content
hint
tivo-schemas-have-descriptions
All schema objects should have descriptions
$.components.schemas[*]
error
tivo-servers-defined
API must define at least one server URL
$
hint
tivo-info-version-semver
API version should follow semantic versioning
$.info.version

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

  tivo-operation-ids-required:
    description: All operations must have operationId values
    message: Operation must have an operationId
    severity: error
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: operationId
      function: defined

  tivo-operation-summaries-required:
    description: All operations must have a summary
    message: Operation must have a summary
    severity: error
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: summary
      function: defined

  tivo-operation-tags-required:
    description: All operations must have at least one tag
    message: Operation must have at least one tag for grouping
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: defined

  tivo-versioned-paths:
    description: All paths must begin with /v3/ for the Video Metadata API
    message: Path {{value}} must begin with /v3/
    severity: error
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: "^/v3/"

  tivo-bearer-auth-required:
    description: API must define bearer token authentication
    message: Security scheme bearerAuth must be defined
    severity: error
    given: $.components.securitySchemes.bearerAuth
    then:
      function: defined

  tivo-response-200-defined:
    description: All GET operations must define a 200 success response
    message: GET operation must have a 200 response defined
    severity: error
    given: $.paths[*].get
    then:
      field: responses.200
      function: defined

  tivo-response-401-defined:
    description: All operations must handle unauthorized responses
    message: Operation must define a 401 unauthorized response
    severity: warn
    given: $.paths[*][get,post]
    then:
      field: responses.401
      function: defined

  tivo-response-404-defined:
    description: Resource lookup operations must handle not found responses
    message: Operations with path parameters must define 404 not found response
    severity: warn
    given: $.paths[*~contains('{')][get]
    then:
      field: responses.404
      function: defined

  tivo-kebab-case-paths:
    description: Path segments must use kebab-case
    message: Path segment must use kebab-case lowercase with hyphens
    severity: warn
    given: $.paths
    then:
      function: pattern
      functionOptions:
        match: "^(/v[0-9]+/[a-z][a-z0-9-]*(/\\{[a-zA-Z]+\\})?(/[a-z][a-z0-9-]*)?)*$"

  tivo-content-type-json:
    description: Response schemas must use application/json content type
    message: Response content type must be application/json
    severity: warn
    given: $.paths[*][*].responses[*].content
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            application/json:
              type: object

  tivo-schemas-have-descriptions:
    description: All schema objects should have descriptions
    message: Schema must include a description
    severity: hint
    given: $.components.schemas[*]
    then:
      field: description
      function: defined

  tivo-servers-defined:
    description: API must define at least one server URL
    message: API must have servers defined
    severity: error
    given: $
    then:
      field: servers
      function: defined

  tivo-info-version-semver:
    description: API version should follow semantic versioning
    message: info.version should use a versioned format like v3
    severity: hint
    given: $.info.version
    then:
      function: pattern
      functionOptions:
        match: "^v[0-9]+"