Vector · API Governance Rules

Vector API Rules

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

16 Rules error 9 warn 7
View Rules File View on GitHub

Rule Categories

health info no openapi operation response schema servers

Rules

error
info-title-required
API title must be present.
$.info
warn
info-title-starts-with-vector
API title should start with "Vector".
$.info.title
warn
info-description-required
API description must be present.
$.info
error
info-version-required
API version must be specified.
$.info
error
openapi-version-3x
Must use OpenAPI 3.x.
$
error
servers-required
Servers array must be defined.
$
warn
servers-description-required
Each server should have a description.
$.servers[*]
error
operation-operationId-required
All operations must have an operationId.
$.paths[*][get,post,put,patch,delete,head]
error
operation-summary-required
All operations must have a summary.
$.paths[*][get,post,put,patch,delete,head]
warn
operation-summary-starts-with-vector
Operation summaries should start with "Vector".
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
All operations should have a description.
$.paths[*][get,post,put,patch,delete,head]
error
response-success-required
Operations must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
All responses must have a description.
$.paths[*][*].responses[*]
warn
schema-description-required
Schema definitions should have descriptions.
$.components.schemas[*]
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description
error
health-endpoint-required
Observability API should expose a /health endpoint.
$.paths

Spectral Ruleset

Raw ↑
rules:

  # INFO / METADATA
  info-title-required:
    description: API title must be present.
    severity: error
    given: "$.info"
    then:
      field: title
      function: truthy

  info-title-starts-with-vector:
    description: API title should start with "Vector".
    severity: warn
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "^Vector"

  info-description-required:
    description: API description must be present.
    severity: warn
    given: "$.info"
    then:
      field: description
      function: truthy

  info-version-required:
    description: API version must be specified.
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version-3x:
    description: Must use OpenAPI 3.x.
    severity: error
    given: "$"
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-required:
    description: Servers array must be defined.
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  servers-description-required:
    description: Each server should have a description.
    severity: warn
    given: "$.servers[*]"
    then:
      field: description
      function: truthy

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

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

  operation-summary-starts-with-vector:
    description: Operation summaries should start with "Vector".
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Vector"

  operation-description-required:
    description: All operations should have a description.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete,head]"
    then:
      field: description
      function: truthy

  # RESPONSES
  response-success-required:
    description: Operations must define at least one 2xx response.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['201']
            - required: ['204']

  response-description-required:
    description: All responses must have a description.
    severity: error
    given: "$.paths[*][*].responses[*]"
    then:
      field: description
      function: truthy

  # SCHEMAS
  schema-description-required:
    description: Schema definitions should have descriptions.
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  # GENERAL QUALITY
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: "$..description"
    then:
      function: pattern
      functionOptions:
        match: ".+"

  health-endpoint-required:
    description: Observability API should expose a /health endpoint.
    severity: error
    given: "$.paths"
    then:
      field: /health
      function: truthy