Vessel · API Governance Rules

Vessel API Rules

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

10 Rules warn 7 info 3
View Rules File View on GitHub

Rule Categories

vessel

Rules

warn
vessel-operation-ids-camel-case
Operation IDs must use camelCase as per Vessel API conventions
$.paths[*][get,post,put,patch,delete].operationId
warn
vessel-require-api-token-security
All operations must declare apiToken security scheme
$.paths[*][get,post,put,patch,delete].security
info
vessel-post-responses-should-return-200
Vessel API uses POST for most operations and returns 200
$.paths[*].post
warn
vessel-require-operation-description
All operations must have a description
$.paths[*][get,post,put,patch,delete]
warn
vessel-require-operation-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
vessel-ids-should-be-strings
All ID fields in schemas should be type string (Vessel normalizes all IDs to strings)
$.components.schemas[*].properties.id
info
vessel-dates-should-be-datetime
Date fields should use date-time format (Vessel normalizes all dates to ISO 8601)
$.components.schemas[*].properties[*At]
warn
vessel-error-responses-should-have-schema
Error responses must include a content schema
$.paths[*][get,post,put,patch,delete].responses['4*','5*'].content['application/json']
info
vessel-require-contact-info
API info must include contact information
$.info
warn
vessel-passthrough-must-have-request-body
The passthrough endpoint must define a request body
$.paths['/passthrough'].post

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  vessel-operation-ids-camel-case:
    description: Operation IDs must use camelCase as per Vessel API conventions
    message: "Operation ID '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  vessel-require-api-token-security:
    description: All operations must declare apiToken security scheme
    message: "Operation must require x-vessel-api-token authentication"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].security"
    then:
      function: truthy

  vessel-post-responses-should-return-200:
    description: Vessel API uses POST for most operations and returns 200
    message: "POST operations should return 200 (Vessel API convention)"
    severity: info
    given: "$.paths[*].post"
    then:
      field: responses
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - '200'

  vessel-require-operation-description:
    description: All operations must have a description
    message: "Operation must include a description"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  vessel-require-operation-tags:
    description: All operations must have at least one tag
    message: "Operations must have at least one tag"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: length
      functionOptions:
        min: 1

  vessel-ids-should-be-strings:
    description: All ID fields in schemas should be type string (Vessel normalizes all IDs to strings)
    message: "ID fields must be type string (Vessel normalizes all IDs)"
    severity: warn
    given: "$.components.schemas[*].properties.id"
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - string

  vessel-dates-should-be-datetime:
    description: Date fields should use date-time format (Vessel normalizes all dates to ISO 8601)
    message: "Date fields should use format date-time"
    severity: info
    given: "$.components.schemas[*].properties[*At]"
    then:
      field: format
      function: enumeration
      functionOptions:
        values:
          - date-time

  vessel-error-responses-should-have-schema:
    description: Error responses must include a content schema
    message: "4xx and 5xx responses must include content schema"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses['4*','5*'].content['application/json']"
    then:
      field: schema
      function: truthy

  vessel-require-contact-info:
    description: API info must include contact information
    message: "API info should include contact information"
    severity: info
    given: "$.info"
    then:
      field: contact
      function: truthy

  vessel-passthrough-must-have-request-body:
    description: The passthrough endpoint must define a request body
    message: "Passthrough endpoint must have a requestBody"
    severity: warn
    given: "$.paths['/passthrough'].post"
    then:
      field: requestBody
      function: truthy