State Street · API Governance Rules

State Street API Rules

Spectral linting rules defining API design standards and conventions for State Street.

16 Rules error 10 warn 6
View Rules File View on GitHub

Rule Categories

state

Rules

error
state-street-info-contact-required
All State Street APIs must include contact information
$.info
error
state-street-operation-summary-title-case
Operation summaries must use Title Case per State Street API standards
$.paths[*][get,post,put,patch,delete].summary
error
state-street-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][get,post,put,patch,delete].operationId
error
state-street-operation-tags-required
All operations must be tagged
$.paths[*][get,post,put,patch,delete]
error
state-street-path-versioned
All paths must start with a version prefix
$.paths
error
state-street-oauth2-required
State Street APIs must use OAuth2 Client Credentials
$.components.securitySchemes[*]
error
state-street-oauth2-client-credentials
OAuth2 must use Client Credentials flow per RFC 6749 Section 4.4.2
$.components.securitySchemes[*][?(@.type=='oauth2')].flows
warn
state-street-correlation-id-header
APIs should support X-Correlation-ID header for request tracing
$.components.parameters
warn
state-street-pagination-get-lists
List operations must support pagination
$.paths[*].get.parameters
warn
state-street-response-429-rate-limit
APIs must document rate limiting responses
$.paths[*][get,post,put,patch,delete].responses
error
state-street-json-default-format
API must use application/json as the primary content type
$.paths[*][get,post,put,patch,delete].responses['200'].content
warn
state-street-schema-description
All schema components must have descriptions
$.components.schemas[*]
warn
state-street-error-schema-consistent
Error responses should reference the standard Error schema
$.paths[*][get,post,put,patch,delete].responses[4*,5*].content['application/json']
error
state-street-security-global
API must apply security globally
$
error
state-street-servers-defined
API must define servers
$
warn
state-street-parameter-description
All parameters must have descriptions
$.paths[*][get,post,put,patch,delete].parameters[*]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:

  state-street-info-contact-required:
    description: All State Street APIs must include contact information
    message: API info must include contact email and URL
    severity: error
    given: $.info
    then:
      - field: contact.email
        function: truthy
      - field: contact.url
        function: truthy

  state-street-operation-summary-title-case:
    description: Operation summaries must use Title Case per State Street API standards
    message: Operation summary must use Title Case
    severity: error
    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]*)*$'

  state-street-operation-id-camel-case:
    description: Operation IDs must use camelCase
    message: OperationId must be camelCase
    severity: error
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]*$'

  state-street-operation-tags-required:
    description: All operations must be tagged
    message: Operation must include at least one tag
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  state-street-path-versioned:
    description: All paths must start with a version prefix
    message: Paths must begin with /v1/ or similar version prefix
    severity: error
    given: $.paths
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: '^/v[0-9]+/'

  state-street-oauth2-required:
    description: State Street APIs must use OAuth2 Client Credentials
    message: API must define OAuth2 security scheme
    severity: error
    given: $.components.securitySchemes[*]
    then:
      field: type
      function: pattern
      functionOptions:
        match: '^oauth2$'

  state-street-oauth2-client-credentials:
    description: OAuth2 must use Client Credentials flow per RFC 6749 Section 4.4.2
    message: OAuth2 scheme must include clientCredentials flow
    severity: error
    given: $.components.securitySchemes[*][?(@.type=='oauth2')].flows
    then:
      field: clientCredentials
      function: truthy

  state-street-correlation-id-header:
    description: APIs should support X-Correlation-ID header for request tracing
    message: API should define X-Correlation-ID parameter for tracing
    severity: warn
    given: $.components.parameters
    then:
      field: XCorrelationId
      function: truthy

  state-street-pagination-get-lists:
    description: List operations must support pagination
    message: GET list operations should support pageSize and pageToken parameters
    severity: warn
    given: $.paths[*].get.parameters
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                enum:
                  - pageSize
                  - pageToken

  state-street-response-429-rate-limit:
    description: APIs must document rate limiting responses
    message: Operations should define 429 Too Many Requests with Retry-After header
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required:
                - '429'
            - required:
                - '200'

  state-street-json-default-format:
    description: API must use application/json as the primary content type
    message: Operations must support application/json content type
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses['200'].content
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - application/json

  state-street-schema-description:
    description: All schema components must have descriptions
    message: Schema component must include a description
    severity: warn
    given: $.components.schemas[*]
    then:
      field: description
      function: truthy

  state-street-error-schema-consistent:
    description: Error responses should reference the standard Error schema
    message: Error responses should reference the reusable Error schema component
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses[4*,5*].content['application/json']
    then:
      field: schema
      function: truthy

  state-street-security-global:
    description: API must apply security globally
    message: API must define global security requirement
    severity: error
    given: $
    then:
      field: security
      function: truthy

  state-street-servers-defined:
    description: API must define servers
    message: API must specify at least one server URL
    severity: error
    given: $
    then:
      field: servers
      function: truthy

  state-street-parameter-description:
    description: All parameters must have descriptions
    message: Parameter must include a description
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: description
      function: truthy