Salesforce Sales Cloud · API Governance Rules

Salesforce Sales Cloud API Rules

Spectral linting rules defining API design standards and conventions for Salesforce Sales Cloud.

10 Rules error 5 warn 4 info 1
View Rules File View on GitHub

Rule Categories

salesforce

Rules

warn
salesforce-sc-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
salesforce-sc-operation-id-camel-case
OperationIds must use camelCase
$.paths[*][*].operationId
warn
salesforce-sc-tags-title-case
All tags must use Title Case
$.paths[*][*].tags[*]
error
salesforce-sc-response-200-description
All 200 responses must have a description
$.paths[*][*].responses['200']
error
salesforce-sc-contact-required
API info must include contact details
$.info
error
salesforce-sc-version-required
API info must include a version
$.info
error
salesforce-sc-servers-required
API must define at least one server
$
error
salesforce-sc-security-defined
API must define security requirements
$
info
salesforce-sc-sobject-paths-lowercase
sObject paths should use standard Salesforce casing conventions
$.paths[*]~
warn
salesforce-sc-bulk-job-content-type
Bulk API job creation should accept application/json
$.paths./jobs/ingest.post.requestBody.content

Spectral Ruleset

Raw ↑
rules:
  salesforce-sc-operation-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' should use Title Case"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  salesforce-sc-operation-id-camel-case:
    description: OperationIds must use camelCase
    message: "OperationId '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  salesforce-sc-tags-title-case:
    description: All tags must use Title Case
    message: "Tag '{{value}}' should use Title Case"
    severity: warn
    given: "$.paths[*][*].tags[*]"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  salesforce-sc-response-200-description:
    description: All 200 responses must have a description
    severity: error
    given: "$.paths[*][*].responses['200']"
    then:
      field: description
      function: truthy

  salesforce-sc-contact-required:
    description: API info must include contact details
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  salesforce-sc-version-required:
    description: API info must include a version
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  salesforce-sc-servers-required:
    description: API must define at least one server
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  salesforce-sc-security-defined:
    description: API must define security requirements
    severity: error
    given: "$"
    then:
      field: security
      function: truthy

  salesforce-sc-sobject-paths-lowercase:
    description: sObject paths should use standard Salesforce casing conventions
    message: "Path '{{value}}' should follow Salesforce sObject naming conventions"
    severity: info
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/[a-zA-Z/{}._-]+$"

  salesforce-sc-bulk-job-content-type:
    description: Bulk API job creation should accept application/json
    message: "Bulk API endpoints should accept application/json content type"
    severity: warn
    given: "$.paths./jobs/ingest.post.requestBody.content"
    then:
      field: application/json
      function: truthy