Salesforce Automation · API Governance Rules

Salesforce Automation API Rules

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

42 Rules error 18 warn 15 info 9
View Rules File View on GitHub

Rule Categories

delete error examples get info no oauth2 openapi operation parameter paths post query request response schema security servers tag

Rules

error
info-title-required
Info object must have a title.
$.info
warn
info-title-salesforce-prefix
Info title should start with "Salesforce".
$.info.title
error
info-description-required
Info object must have a description.
$.info
warn
info-description-min-length
Info description should be at least 50 characters.
$.info.description
error
info-version-required
Info object must have a version.
$.info
warn
info-contact-required
Info object should have contact information.
$.info
info
info-license-required
Info object should include license information.
$.info
warn
openapi-version
OpenAPI version should be 3.1.0.
$
error
servers-defined
At least one server must be defined.
$
error
servers-https
Server URLs should use HTTPS.
$.servers[*].url
warn
servers-description
Each server should have a description.
$.servers[*]
error
paths-no-trailing-slash
Paths must not have trailing slashes.
$.paths
error
paths-no-query-strings
Paths must not include query strings.
$.paths
info
paths-kebab-case
Path segments should use kebab-case or camelCase (no underscores).
$.paths
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-camel-case
operationId should use camelCase.
$.paths[*][get,post,put,patch,delete].operationId
error
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-salesforce-prefix
Operation summaries should start with "Salesforce".
$.paths[*][get,post,put,patch,delete].summary
error
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
info
tag-description
Tags should have descriptions.
$.tags[*]
warn
parameter-description-required
Every parameter must have a description.
$.paths[*][*].parameters[*]
error
parameter-schema-required
Every parameter must have a schema.
$.paths[*][*].parameters[*]
warn
request-body-json-content
Request bodies should use application/json content type.
$.paths[*][post,put,patch].requestBody.content
error
response-success-required
Every operation must have at least one success response (2xx).
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
Every response must have a description.
$.paths[*][*].responses[*]
info
response-401-required
Authenticated endpoints should define a 401 response.
$.paths[*][get,post,put,patch,delete].responses
warn
schema-type-defined
Schemas must define a type.
$.components.schemas[*]
info
schema-description
Top-level schemas should have descriptions.
$.components.schemas[*]
error
security-defined
Global security must be defined.
$
error
security-schemes-defined
Security schemes must be defined in components.
$.components
error
get-no-request-body
GET operations must not have a request body.
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not have a request body.
$.paths[*].delete
info
post-request-body-required
POST operations should have a request body.
$.paths[*].post
error
no-empty-descriptions
Descriptions must not be empty strings.
$..description
info
examples-encouraged
Schema properties should include example values.
$.components.schemas[*].properties[*]
warn
oauth2-security
Salesforce APIs should use OAuth 2.0 authentication.
$.components.securitySchemes
warn
servers-expected-domain
Server URLs should be on the salesforce.com domain.
$.servers[*].url
info
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (ApiError) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# salesforce-automation — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 12/12 servers on salesforce.com
#   - path-params-casing: camel @ 100% (n=67)
#   - query-params-casing: snake @ 56% (n=41)
#   - operationid-casing: camel @ 98% (n=104)
#   - schema-names-casing: pascal @ 100% (n=71)
#   - schema-properties-casing: snake @ 48% (n=341)
#   - security: global (root) — NOT emitting operation-security-required
#   - error-schema-defined: ApiError
#   - pagination params observed: ['page', 'pageSize']
#   - merge: kept 37 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info object must have a title.
    given: $.info
    severity: error
    then:
      field: title
      function: truthy
  info-title-salesforce-prefix:
    description: Info title should start with "Salesforce".
    given: $.info.title
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^Salesforce
  info-description-required:
    description: Info object must have a description.
    given: $.info
    severity: error
    then:
      field: description
      function: truthy
  info-description-min-length:
    description: Info description should be at least 50 characters.
    given: $.info.description
    severity: warn
    then:
      function: length
      functionOptions:
        min: 50
  info-version-required:
    description: Info object must have a version.
    given: $.info
    severity: error
    then:
      field: version
      function: truthy
  info-contact-required:
    description: Info object should have contact information.
    given: $.info
    severity: warn
    then:
      field: contact
      function: truthy
  info-license-required:
    description: Info object should include license information.
    given: $.info
    severity: info
    then:
      field: license
      function: truthy
  openapi-version:
    description: OpenAPI version should be 3.1.0.
    given: $
    severity: warn
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-defined:
    description: At least one server must be defined.
    given: $
    severity: error
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs should use HTTPS.
    given: $.servers[*].url
    severity: error
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-description:
    description: Each server should have a description.
    given: $.servers[*]
    severity: warn
    then:
      field: description
      function: truthy
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes.
    given: $.paths
    severity: error
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: \/$
  paths-no-query-strings:
    description: Paths must not include query strings.
    given: $.paths
    severity: error
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: \?
  paths-kebab-case:
    description: Path segments should use kebab-case or camelCase (no underscores).
    given: $.paths
    severity: info
    then:
      field: '@key'
      function: pattern
      functionOptions:
        notMatch: _
  operation-operationid-required:
    description: Every operation must have an operationId.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: operationId
      function: truthy
  operation-operationid-camel-case:
    description: operationId should use camelCase.
    given: $.paths[*][get,post,put,patch,delete].operationId
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-summary-required:
    description: Every operation must have a summary.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: summary
      function: truthy
  operation-summary-salesforce-prefix:
    description: Operation summaries should start with "Salesforce".
    given: $.paths[*][get,post,put,patch,delete].summary
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: ^Salesforce
  operation-description-required:
    description: Every operation must have a description.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: Every operation must have at least one tag.
    given: $.paths[*][get,post,put,patch,delete]
    severity: error
    then:
      field: tags
      function: truthy
  tag-description:
    description: Tags should have descriptions.
    given: $.tags[*]
    severity: info
    then:
      field: description
      function: truthy
  parameter-description-required:
    description: Every parameter must have a description.
    given: $.paths[*][*].parameters[*]
    severity: warn
    then:
      field: description
      function: truthy
  parameter-schema-required:
    description: Every parameter must have a schema.
    given: $.paths[*][*].parameters[*]
    severity: error
    then:
      field: schema
      function: truthy
  request-body-json-content:
    description: Request bodies should use application/json content type.
    given: $.paths[*][post,put,patch].requestBody.content
    severity: warn
    then:
      field: application/json
      function: truthy
  response-success-required:
    description: Every operation must have at least one success response (2xx).
    given: $.paths[*][get,post,put,patch,delete].responses
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - '200'
          - required:
            - '201'
          - required:
            - '202'
          - required:
            - '204'
  response-description-required:
    description: Every response must have a description.
    given: $.paths[*][*].responses[*]
    severity: error
    then:
      field: description
      function: truthy
  response-401-required:
    description: Authenticated endpoints should define a 401 response.
    given: $.paths[*][get,post,put,patch,delete].responses
    severity: info
    then:
      field: '401'
      function: truthy
  schema-type-defined:
    description: Schemas must define a type.
    given: $.components.schemas[*]
    severity: warn
    then:
      field: type
      function: truthy
  schema-description:
    description: Top-level schemas should have descriptions.
    given: $.components.schemas[*]
    severity: info
    then:
      field: description
      function: truthy
  security-defined:
    description: Global security must be defined.
    given: $
    severity: error
    then:
      field: security
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined in components.
    given: $.components
    severity: error
    then:
      field: securitySchemes
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body.
    given: $.paths[*].get
    severity: error
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    description: DELETE operations should not have a request body.
    given: $.paths[*].delete
    severity: warn
    then:
      field: requestBody
      function: falsy
  post-request-body-required:
    description: POST operations should have a request body.
    given: $.paths[*].post
    severity: info
    then:
      field: requestBody
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    given: $..description
    severity: error
    then:
      function: truthy
  examples-encouraged:
    description: Schema properties should include example values.
    given: $.components.schemas[*].properties[*]
    severity: info
    then:
      field: example
      function: truthy
  oauth2-security:
    description: Salesforce APIs should use OAuth 2.0 authentication.
    given: $.components.securitySchemes
    severity: warn
    then:
      field: oauth2
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the salesforce.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: salesforce\.com
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: info
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (ApiError) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: ApiError
      function: truthy