SaaSHub · API Governance Rules

SaaSHub API Rules

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

7 Rules error 1 warn 6
View Rules File View on GitHub

Rule Categories

saashub

Rules

warn
saashub-summary-title-case
All operation summaries must use Title Case
$.paths[*][*].summary
warn
saashub-tags-title-case
All tags must use Title Case
$.paths[*][*].tags[*]
error
saashub-api-key-required
API key query parameter must be present on all operations
$.paths[*][get]
warn
saashub-operation-ids-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
saashub-path-params-have-examples
Path parameters should include examples
$.paths[*][*].parameters[?(@.in == 'path')]
warn
saashub-responses-include-json
Successful responses must return application/json
$.paths[*][*].responses[?(@property.match(/^2/))]
warn
saashub-jsonapi-response-structure
Responses should follow JSON:API structure with data field
$.components.schemas[*]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  saashub-summary-title-case:
    description: All operation summaries must use Title Case
    message: "Operation summary '{{value}}' must use Title Case"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*(\\s[A-Z][a-zA-Z0-9]*)*$"

  saashub-tags-title-case:
    description: All tags must use Title Case
    message: "Tag '{{value}}' must use Title Case"
    severity: warn
    given: "$.paths[*][*].tags[*]"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*(\\s[A-Z][a-zA-Z0-9]*)*$"

  saashub-api-key-required:
    description: API key query parameter must be present on all operations
    message: "All SaaSHub API operations require an api_key query parameter"
    severity: error
    given: "$.paths[*][get]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  saashub-operation-ids-camel-case:
    description: Operation IDs must use camelCase
    message: "Operation ID '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  saashub-path-params-have-examples:
    description: Path parameters should include examples
    message: "Path parameter should include an example value"
    severity: warn
    given: "$.paths[*][*].parameters[?(@.in == 'path')]"
    then:
      field: schema.example
      function: truthy

  saashub-responses-include-json:
    description: Successful responses must return application/json
    message: "2xx responses should include application/json content"
    severity: warn
    given: "$.paths[*][*].responses[?(@property.match(/^2/))]"
    then:
      field: content
      function: truthy

  saashub-jsonapi-response-structure:
    description: Responses should follow JSON:API structure with data field
    message: "Response schema should include a 'data' property per JSON:API spec"
    severity: warn
    given: "$.components.schemas[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object