Trimble Navigation · API Governance Rules

Trimble Navigation API Rules

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

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

Rule Categories

trimble

Rules

error
trimble-nav-operation-id-required
All operations must have a camelCase operationId
$.paths[*][get,post,put,delete,patch]
warn
trimble-nav-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][get,post,put,delete,patch].operationId
warn
trimble-nav-versioned-path
All API paths must use versioned prefix
$.paths[*]~
error
trimble-nav-response-200-required
All operations must define a 200 success response
$.paths[*][get,post,put,delete,patch].responses
warn
trimble-nav-operation-tags-required
All operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
warn
trimble-nav-basic-auth
API must use basic auth with computed access code
$.components.securitySchemes[*]
warn
trimble-nav-coordinate-precision
Latitude and longitude must use double precision
$.components.schemas[*].properties[?(@property == 'latitude' || @property == 'longitude')]
error
trimble-nav-path-params-required
Path parameters must be required
$.paths[*][*].parameters[?(@.in == 'path')]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

  # All operations must have operationId
  trimble-nav-operation-id-required:
    description: All operations must have a camelCase operationId
    message: "Operation is missing operationId"
    severity: error
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: operationId
      function: truthy

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

  # API paths must be versioned
  trimble-nav-versioned-path:
    description: All API paths must use versioned prefix
    message: "Path '{{value}}' must start with /api/v1/ or /api/v2/"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/api/v[12]/"

  # All operations must define a 200 response
  trimble-nav-response-200-required:
    description: All operations must define a 200 success response
    message: "Operation is missing a 200 success response"
    severity: error
    given: "$.paths[*][get,post,put,delete,patch].responses"
    then:
      field: "200"
      function: truthy

  # All operations must have tags
  trimble-nav-operation-tags-required:
    description: All operations must have at least one tag
    message: "Operation must have at least one tag"
    severity: warn
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  # Basic auth must be used
  trimble-nav-basic-auth:
    description: API must use basic auth with computed access code
    message: "Security scheme must use HTTP basic authentication"
    severity: warn
    given: "$.components.securitySchemes[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              const: http
            scheme:
              const: basic

  # Coordinate fields must use double precision
  trimble-nav-coordinate-precision:
    description: Latitude and longitude must use double precision
    message: "Coordinate field should use format: double for sub-centimeter precision"
    severity: warn
    given: "$.components.schemas[*].properties[?(@property == 'latitude' || @property == 'longitude')]"
    then:
      field: format
      function: enumeration
      functionOptions:
        values:
          - double

  # Path parameters must be required
  trimble-nav-path-params-required:
    description: Path parameters must be required
    message: "Path parameter must have required: true"
    severity: error
    given: "$.paths[*][*].parameters[?(@.in == 'path')]"
    then:
      field: required
      function: truthy