Sendcloud · API Governance Rules

Sendcloud API Rules

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

15 Rules error 3 warn 8 info 4
View Rules File View on GitHub

Rule Categories

sendcloud

Rules

warn
sendcloud-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][get,post,put,patch,delete].operationId
warn
sendcloud-path-kebab-case
Path segments must use kebab-case or curly-brace parameters
$.paths
error
sendcloud-must-have-summary
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
sendcloud-must-have-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
error
sendcloud-must-have-operation-id
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
sendcloud-response-200-must-have-schema
200 responses must have a content schema
$.paths[*][get,post,put,patch,delete].responses[200]
warn
sendcloud-post-must-have-request-body
POST operations should have a request body
$.paths[*].post
warn
sendcloud-security-defined
All operations should have security defined at root or operation level
$.paths[*][get,post,put,patch,delete]
info
sendcloud-basic-auth-or-oauth2
Sendcloud supports HTTP Basic (public/private key) and OAuth 2.0 client_credentials authentication
$.components.securitySchemes[*]
info
sendcloud-cursor-pagination
List operations should support cursor-based pagination
$.paths[*].get.parameters[?(@.name=='cursor')]
warn
sendcloud-base-url-versioned
Servers should use the /api/v2 or /api/v3 versioned base path on panel.sendcloud.sc
$.servers[*].url
error
sendcloud-no-trailing-slash
Paths must not have trailing slashes
$.paths
info
sendcloud-parameters-have-description
All parameters should have a description
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
sendcloud-components-schemas-exist
OpenAPI spec should define component schemas
$.components
info
sendcloud-error-object-standard
Error responses should use the shared ErrorObject component schema
$.paths[*][get,post,put,patch,delete].responses[400,401,403,404,409,422,429,500]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Sendcloud API Naming Conventions

  sendcloud-operation-id-camel-case:
    description: Operation IDs must use camelCase
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  sendcloud-path-kebab-case:
    description: Path segments must use kebab-case or curly-brace parameters
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9{}_-]+)+$"

  sendcloud-must-have-summary:
    description: All operations must have a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: defined

  sendcloud-must-have-tags:
    description: All operations must have at least one tag
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: defined

  sendcloud-must-have-operation-id:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: defined

  sendcloud-response-200-must-have-schema:
    description: 200 responses must have a content schema
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses[200]"
    then:
      field: content
      function: defined

  sendcloud-post-must-have-request-body:
    description: POST operations should have a request body
    severity: warn
    given: "$.paths[*].post"
    then:
      field: requestBody
      function: defined

  sendcloud-security-defined:
    description: All operations should have security defined at root or operation level
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      function: schema
      functionOptions:
        schema:
          oneOf:
            - required: [security]

  sendcloud-basic-auth-or-oauth2:
    description: Sendcloud supports HTTP Basic (public/private key) and OAuth 2.0 client_credentials authentication
    severity: info
    given: "$.components.securitySchemes[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  sendcloud-cursor-pagination:
    description: List operations should support cursor-based pagination
    severity: info
    given: "$.paths[*].get.parameters[?(@.name=='cursor')]"
    then:
      field: in
      function: defined

  sendcloud-base-url-versioned:
    description: Servers should use the /api/v2 or /api/v3 versioned base path on panel.sendcloud.sc
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://panel\\.sendcloud\\.sc/api/v[23]$"

  sendcloud-no-trailing-slash:
    description: Paths must not have trailing slashes
    severity: error
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: ".*/$"

  sendcloud-parameters-have-description:
    description: All parameters should have a description
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].parameters[*]"
    then:
      field: description
      function: defined

  sendcloud-components-schemas-exist:
    description: OpenAPI spec should define component schemas
    severity: warn
    given: "$.components"
    then:
      field: schemas
      function: defined

  sendcloud-error-object-standard:
    description: Error responses should use the shared ErrorObject component schema
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].responses[400,401,403,404,409,422,429,500]"
    then:
      field: content
      function: defined