Vendr · API Governance Rules

Vendr API Rules

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

11 Rules error 3 warn 7
View Rules File View on GitHub

Rule Categories

vendr

Rules

error
vendr-path-version-prefix
All Vendr API paths must be prefixed with /v1/
$.paths[*]~
warn
vendr-security-defined
All operations must require X-API-Key authentication
$.paths[*][*]
warn
vendr-path-kebab-case
Path segments must use kebab-case
$.paths[*]~
error
vendr-operation-id-required
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
vendr-operation-id-camel-case
operationId should use camelCase
$.paths[*][get,post,put,patch,delete].operationId
error
vendr-operation-summary-required
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
vendr-summary-title-case
Operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
warn
vendr-401-response-required
Authenticated operations must include a 401 response
$.paths[*][get,post,put,patch,delete].responses
warn
vendr-429-response-required
Operations must document rate limit (429) responses
$.paths[*][get,post,put,patch,delete].responses
warn
vendr-info-contact
API info must include contact information
$.info
hint
vendr-schema-description
Schema properties should have descriptions
$.components.schemas[*].properties[*]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Vendr API uses /v1/ prefix on all paths
  vendr-path-version-prefix:
    description: All Vendr API paths must be prefixed with /v1/
    message: "Path '{{value}}' must start with /v1/"
    severity: error
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/v1/"

  # Vendr API key auth via X-API-Key header
  vendr-security-defined:
    description: All operations must require X-API-Key authentication
    message: Operations must have security defined
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: security
      function: truthy

  # Vendr uses kebab-case path segments
  vendr-path-kebab-case:
    description: Path segments must use kebab-case
    message: "Path segment '{{value}}' must use kebab-case (lowercase with hyphens)"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/v1)(/[a-z0-9]+(-[a-z0-9]+)*(/{[a-zA-Z]+})?)*$"

  # All operations must have operationId
  vendr-operation-id-required:
    description: All operations must have an operationId
    message: Operation must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  # operationId should be camelCase
  vendr-operation-id-camel-case:
    description: operationId should use camelCase
    message: "operationId '{{value}}' should use camelCase"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

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

  # Summaries must be Title Case
  vendr-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-Z]*(\\s[A-Z][a-zA-Z]*)*$"

  # Responses must include 401 for authenticated endpoints
  vendr-401-response-required:
    description: Authenticated operations must include a 401 response
    message: Operation must define a 401 Unauthorized response
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: truthy

  # Responses must include 429 rate limit response
  vendr-429-response-required:
    description: Operations must document rate limit (429) responses
    message: Operation must define a 429 Too Many Requests response
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "429"
      function: truthy

  # Info must have contact
  vendr-info-contact:
    description: API info must include contact information
    message: API info must include contact details
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  # All schemas should have descriptions
  vendr-schema-description:
    description: Schema properties should have descriptions
    message: Schema property should have a description
    severity: hint
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy