Uniblock · API Governance Rules

Uniblock API Rules

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

8 Rules error 3 warn 4 info 1
View Rules File View on GitHub

Rule Categories

uniblock

Rules

error
uniblock-operation-ids-required
All operations must have an operationId
$.paths[*][get,post,put,patch,delete,options,head]
warn
uniblock-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
warn
uniblock-tags-required
Operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
uniblock-chain-param-described
Chain parameters must have a description
$.components.parameters[?(@.name == "chain" || @.name == "chainId")]
error
uniblock-api-key-security
API must define API key security scheme
$.components.securitySchemes
warn
uniblock-responses-include-error
Operations should document 401 unauthorized response
$.paths[*][get,post].responses
error
uniblock-servers-required
API must define at least one server
$
info
uniblock-blockchain-address-format
Parameters accepting blockchain addresses should note expected format
$.paths[*][*].parameters[?(@.name == "address" || @.name == "contractAddress")]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  uniblock-operation-ids-required:
    description: All operations must have an operationId
    message: Operation must have an operationId
    severity: error
    given: $.paths[*][get,post,put,patch,delete,options,head]
    then:
      field: operationId
      function: truthy

  uniblock-operation-summary-title-case:
    description: Operation summaries must use Title Case
    message: Summary "{{value}}" must use Title Case
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^[A-Z][a-zA-Z0-9]*([ ][a-zA-Z0-9]+)*$'

  uniblock-tags-required:
    description: Operations must have at least one tag
    message: Operation must include at least one tag
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  uniblock-chain-param-described:
    description: Chain parameters must have a description
    message: Chain parameter must include a description explaining supported networks
    severity: warn
    given: $.components.parameters[?(@.name == "chain" || @.name == "chainId")]
    then:
      field: description
      function: truthy

  uniblock-api-key-security:
    description: API must define API key security scheme
    message: Uniblock APIs use API key authentication in the x-api-key header
    severity: error
    given: $.components.securitySchemes
    then:
      function: truthy

  uniblock-responses-include-error:
    description: Operations should document 401 unauthorized response
    message: Operation should document 401 Unauthorized for API key validation errors
    severity: warn
    given: $.paths[*][get,post].responses
    then:
      field: '401'
      function: truthy

  uniblock-servers-required:
    description: API must define at least one server
    message: API must include a servers array with at least one entry
    severity: error
    given: $
    then:
      field: servers
      function: truthy

  uniblock-blockchain-address-format:
    description: Parameters accepting blockchain addresses should note expected format
    message: Blockchain address parameter should document address format in description
    severity: info
    given: $.paths[*][*].parameters[?(@.name == "address" || @.name == "contractAddress")]
    then:
      field: description
      function: truthy