Golioth · API Governance Rules

Golioth API Rules

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

7 Rules warn 5
View Rules File View on GitHub

Rule Categories

golioth

Rules

warn
golioth-summary-title-case
Operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
hint
golioth-summary-prefix
Operation summaries used in the API Evangelist catalog must begin with 'Golioth '
$.paths[*][get,post,put,patch,delete].summary
warn
golioth-security-scheme
Operations must reference the x-api-key security scheme
$.components.securitySchemes
warn
golioth-versioned-paths
Management API paths must be prefixed with /v1
$.paths[*]~
hint
golioth-project-scope
Project-scoped resources must include the {projectId} segment
$.paths[?(@property.startsWith('/v1/projects/'))]
warn
golioth-success-response
Every operation should declare a 200 or 201 response
$.paths[*][get,post,put,patch,delete].responses
warn
golioth-operation-tagged
Operations should have at least one tag
$.paths[*][get,post,put,patch,delete]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:
  # Golioth uses Title Case for all operation summaries
  golioth-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' should use Title Case"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  # Golioth uses the "Golioth " prefix in catalog-canonical summaries
  golioth-summary-prefix:
    description: Operation summaries used in the API Evangelist catalog must begin with 'Golioth '
    message: "Summary '{{value}}' must begin with 'Golioth '"
    severity: hint
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^Golioth "

  # Golioth uses an x-api-key header for project-scoped auth on the Management API
  golioth-security-scheme:
    description: Operations must reference the x-api-key security scheme
    severity: warn
    given: "$.components.securitySchemes"
    then:
      field: apiKey
      function: defined

  # All Management API paths must be versioned with /v1
  golioth-versioned-paths:
    description: Management API paths must be prefixed with /v1
    message: "Path '{{path}}' should start with /v1"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/v1/"

  # Project-scoped resources must include {projectId} in the path
  golioth-project-scope:
    description: Project-scoped resources must include the {projectId} segment
    severity: hint
    given: "$.paths[?(@property.startsWith('/v1/projects/'))]"
    then:
      function: truthy

  # Every operation should declare a 200/201 response
  golioth-success-response:
    description: Every operation should declare a 200 or 201 response
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['200']
            - required: ['201']
            - required: ['204']

  # Operations should declare at least one tag
  golioth-operation-tagged:
    description: Operations should have at least one tag
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: defined