Trimble · API Governance Rules

Trimble API Rules

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

12 Rules error 3 warn 8
View Rules File View on GitHub

Rule Categories

trimble

Rules

warn
trimble-operation-ids-camel-case
Operation IDs must use camelCase naming convention
$.paths[*][get,post,put,patch,delete,head,options].operationId
warn
trimble-operation-summary-title-case
Operation summaries should use Title Case
$.paths[*][get,post,put,patch,delete].summary
error
trimble-operation-has-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete,head,options]
warn
trimble-tag-title-case
Tags must use Title Case
$.paths[*][get,post,put,patch,delete].tags[*]
warn
trimble-operation-description
All operations should have a description
$.paths[*][get,post,put,patch,delete]
warn
trimble-bearer-auth-scheme
Bearer auth security scheme should be named BearerAuth
$.components.securitySchemes
warn
trimble-response-200-schema
Successful GET responses must define a response schema
$.paths[*].get.responses.200.content.application/json
warn
trimble-project-id-path-param
Project ID path parameters must be named projectId
$.paths[*][get,post,put,patch,delete].parameters[?(@.in == 'path')]
hint
trimble-connect-pagination-params
List operations should include pagination parameters
$.paths[*].get
warn
trimble-error-responses
Operations should define 401 Unauthorized response
$.paths[*][get,post,put,patch,delete].responses
error
trimble-no-x-internal
Internal-only operations must not appear in public API specifications
$.paths[*][get,post,put,patch,delete]
error
trimble-api-version-in-info
API specification must include a version in info object
$.info

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

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

  trimble-operation-summary-title-case:
    description: Operation summaries should use Title Case
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ,()\\-']+$"

  trimble-operation-has-tags:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][get,post,put,patch,delete,head,options]"
    then:
      field: tags
      function: truthy

  trimble-tag-title-case:
    description: Tags must use Title Case
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].tags[*]"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 \\-]*$"

  trimble-operation-description:
    description: All operations should have a description
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  trimble-bearer-auth-scheme:
    description: Bearer auth security scheme should be named BearerAuth
    severity: warn
    given: "$.components.securitySchemes"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            BearerAuth:
              type: object

  trimble-response-200-schema:
    description: Successful GET responses must define a response schema
    severity: warn
    given: "$.paths[*].get.responses.200.content.application/json"
    then:
      field: schema
      function: defined

  trimble-project-id-path-param:
    description: Project ID path parameters must be named projectId
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].parameters[?(@.in == 'path')]"
    then:
      function: schema
      functionOptions:
        schema:
          if:
            properties:
              name:
                pattern: ".*[Pp]roject.*[Ii]d.*"
          then:
            properties:
              name:
                const: projectId

  trimble-connect-pagination-params:
    description: List operations should include pagination parameters
    severity: hint
    given: "$.paths[*].get"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  trimble-error-responses:
    description: Operations should define 401 Unauthorized response
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            "401":
              type: object

  trimble-no-x-internal:
    description: Internal-only operations must not appear in public API specifications
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: x-internal
      function: falsy

  trimble-api-version-in-info:
    description: API specification must include a version in info object
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy