SSO · API Governance Rules

SSO API Rules

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

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

Rule Categories

sso

Rules

warn
sso-operation-summaries-title-case
All SSO API operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
error
sso-security-scheme-defined
SSO APIs must define security schemes
$.components
warn
sso-paths-must-have-summary
All SSO API operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
sso-paths-kebab-case
SSO API paths should use kebab-case
$.paths[*]~
error
sso-operations-must-have-operationid
All SSO API operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
sso-operationid-camel-case
SSO API operationIds must use camelCase
$.paths[*][get,post,put,patch,delete].operationId
warn
sso-response-200-or-2xx
SSO API operations should define at least one 2xx response
$.paths[*][get,post,put,patch,delete].responses
warn
sso-tags-must-be-defined
All tags used in operations must be defined in the global tags list
$.paths[*][get,post,put,patch,delete].tags[*]
warn
sso-info-contact
SSO API specs must include contact information
$.info
error
sso-servers-defined
SSO API specs must define at least one server
$

Spectral Ruleset

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

  sso-security-scheme-defined:
    description: SSO APIs must define security schemes
    message: "SSO API spec must define at least one security scheme in components/securitySchemes"
    severity: error
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

  sso-paths-must-have-summary:
    description: All SSO API operations must have a summary
    message: "Operation {{path}} must have a summary"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  sso-paths-kebab-case:
    description: SSO API paths should use kebab-case
    message: "Path segment '{{value}}' must use kebab-case"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9{][a-z0-9-{}/.]*)*$"

  sso-operations-must-have-operationid:
    description: All SSO API operations must have an operationId
    message: "Operation {{path}} is missing an operationId"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  sso-operationid-camel-case:
    description: SSO API operationIds must use camelCase
    message: "operationId '{{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]*$"

  sso-response-200-or-2xx:
    description: SSO API operations should define at least one 2xx response
    message: "Operation must define at least one 2xx success response"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  sso-tags-must-be-defined:
    description: All tags used in operations must be defined in the global tags list
    message: "Tag '{{value}}' is used in an operation but not defined globally"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].tags[*]"
    then:
      function: truthy

  sso-info-contact:
    description: SSO API specs must include contact information
    message: "SSO API spec must have info.contact defined"
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  sso-servers-defined:
    description: SSO API specs must define at least one server
    message: "SSO API spec must define at least one server entry"
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy