Symphony · API Governance Rules

Symphony API Rules

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

10 Rules error 2 warn 7
View Rules File View on GitHub

Rule Categories

symphony

Rules

warn
symphony-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
symphony-operation-has-operation-id
All operations must have an operationId
$.paths[*][get,post,put,delete,patch]
warn
symphony-operation-has-tags
All operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
hint
symphony-session-token-header
Symphony APIs require sessionToken header on authenticated endpoints
$.paths[*][get,post,put,delete,patch].parameters[?(@.name == 'sessionToken')]
warn
symphony-error-response-defined
Operations should define error responses (4xx/5xx)
$.paths[*][get,post,put,delete,patch].responses
warn
symphony-v-prefixed-paths
Symphony API paths should be versioned with /v{n}/ prefix
$.paths
warn
symphony-no-trailing-slash
API paths must not have trailing slashes
$.paths
error
symphony-response-200-defined
All operations must define a 200 or 2xx success response
$.paths[*][get,post,put,delete,patch].responses
warn
symphony-info-contact
API info should include contact information
$.info
warn
symphony-server-defined
API must define at least one server
$

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

  symphony-operation-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' must use Title Case"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

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

  symphony-operation-has-tags:
    description: All operations must have at least one tag
    message: Operation is missing tags
    severity: warn
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: tags
      function: truthy

  symphony-session-token-header:
    description: Symphony APIs require sessionToken header on authenticated endpoints
    message: Authenticated operations should reference sessionToken parameter
    severity: hint
    given: "$.paths[*][get,post,put,delete,patch].parameters[?(@.name == 'sessionToken')]"
    then:
      field: in
      function: enumeration
      functionOptions:
        values:
          - header

  symphony-error-response-defined:
    description: Operations should define error responses (4xx/5xx)
    message: Operation is missing error response definitions
    severity: warn
    given: "$.paths[*][get,post,put,delete,patch].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["400"]
            - required: ["401"]
            - required: ["403"]
            - required: ["500"]

  symphony-v-prefixed-paths:
    description: Symphony API paths should be versioned with /v{n}/ prefix
    message: "Path '{{property}}' should start with a version prefix (e.g. /v1/)"
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^\\/v[0-9]"

  symphony-no-trailing-slash:
    description: API paths must not have trailing slashes
    message: "Path '{{property}}' must not have a trailing slash"
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: "\\/$"

  symphony-response-200-defined:
    description: All operations must define a 200 or 2xx success response
    message: Operation is missing a success response
    severity: error
    given: "$.paths[*][get,post,put,delete,patch].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["200"]
            - required: ["201"]
            - required: ["204"]

  symphony-info-contact:
    description: API info should include contact information
    message: API info is missing contact details
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  symphony-server-defined:
    description: API must define at least one server
    message: API is missing server definitions
    severity: warn
    given: "$"
    then:
      field: servers
      function: truthy