Copper · API Governance Rules

Copper API Rules

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

14 Rules error 6 warn 7 info 1
View Rules File View on GitHub

Rule Categories

copper

Rules

error
copper-info-contact
API info object should include contact information.
$.info
warn
copper-info-license
API info object should include license information.
$.info
error
copper-server-https
All servers must use HTTPS.
$.servers[*].url
warn
copper-base-url
Servers should reference the Copper Developer API host.
$.servers[*].url
error
copper-required-auth-headers
Operations should be protected by Copper auth headers.
$.security
error
copper-operation-tags
Every operation must have at least one tag.
$.paths.*[get,post,put,delete,patch]
error
copper-operation-summary
Every operation must have a summary.
$.paths.*[get,post,put,delete,patch]
warn
copper-operation-description
Operations should include a description.
$.paths.*[get,post,put,delete,patch]
error
copper-operation-id
Every operation must have an operationId in camelCase.
$.paths.*[get,post,put,delete,patch]
warn
copper-pagination-params
Search endpoints should support page_number and page_size parameters.
$.paths['/people/search','/companies/search','/leads/search','/opportunities/search','/tasks/search','/activities/search'].post.requestBody.content.application/json.schema
warn
copper-tag-pascal-case
Tags should use PascalCase plural resource names.
$.tags[*].name
info
copper-rate-limit-documented
API description should mention rate limits.
$.info.description
warn
copper-error-schema
Error responses should reference an Error schema.
$.components.schemas
warn
copper-resource-id-integer
Resource id fields should be int64 integers.
$.components.schemas.*.properties.id

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]
documentationUrl: https://developer.copper.com/
rules:
  copper-info-contact:
    description: API info object should include contact information.
    message: "{{description}}: info.contact is required."
    given: "$.info"
    severity: error
    then:
      field: contact
      function: truthy
  copper-info-license:
    description: API info object should include license information.
    given: "$.info"
    severity: warn
    then:
      field: license
      function: truthy
  copper-server-https:
    description: All servers must use HTTPS.
    given: "$.servers[*].url"
    severity: error
    then:
      function: pattern
      functionOptions:
        match: "^https://"
  copper-base-url:
    description: Servers should reference the Copper Developer API host.
    given: "$.servers[*].url"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "api.copper.com/developer_api"
  copper-required-auth-headers:
    description: Operations should be protected by Copper auth headers.
    given: "$.security"
    severity: error
    then:
      function: truthy
  copper-operation-tags:
    description: Every operation must have at least one tag.
    given: "$.paths.*[get,post,put,delete,patch]"
    severity: error
    then:
      field: tags
      function: truthy
  copper-operation-summary:
    description: Every operation must have a summary.
    given: "$.paths.*[get,post,put,delete,patch]"
    severity: error
    then:
      field: summary
      function: truthy
  copper-operation-description:
    description: Operations should include a description.
    given: "$.paths.*[get,post,put,delete,patch]"
    severity: warn
    then:
      field: description
      function: truthy
  copper-operation-id:
    description: Every operation must have an operationId in camelCase.
    given: "$.paths.*[get,post,put,delete,patch]"
    severity: error
    then:
      field: operationId
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"
  copper-pagination-params:
    description: Search endpoints should support page_number and page_size parameters.
    given: "$.paths['/people/search','/companies/search','/leads/search','/opportunities/search','/tasks/search','/activities/search'].post.requestBody.content.application/json.schema"
    severity: warn
    then:
      function: truthy
  copper-tag-pascal-case:
    description: Tags should use PascalCase plural resource names.
    given: "$.tags[*].name"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z]+s?$"
  copper-rate-limit-documented:
    description: API description should mention rate limits.
    given: "$.info.description"
    severity: info
    then:
      function: pattern
      functionOptions:
        match: "rate|limit|180|3 requests"
  copper-error-schema:
    description: Error responses should reference an Error schema.
    given: "$.components.schemas"
    severity: warn
    then:
      field: Error
      function: truthy
  copper-resource-id-integer:
    description: Resource id fields should be int64 integers.
    given: "$.components.schemas.*.properties.id"
    severity: warn
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - integer