Skip to content

DriftResult

Drift detection result with severity classification.

Type Definition

typescript
interface DriftResult {
  type: DriftType
  severity: Severity
  method: HttpMethod
  path: string
  message: string
  details: DriftDetails
  suggestions?: string[]
}

Fields

FieldTypeDescription
typeDriftTypeType of drift detected
severitySeverityImpact severity level
methodHttpMethodHTTP method of endpoint
pathstringEndpoint path
messagestringHuman-readable drift description
detailsDriftDetailsDetailed drift information
suggestionsstring[]?Fix suggestions

DriftType

8 drift types:

typescript
type DriftType =
  | 'missing-endpoint'       // 🔴 Critical
  | 'phantom-endpoint'       // 🔴 Critical
  | 'type-mismatch'          // 🔴 High
  | 'missing-field'          // 🔴 High
  | 'extra-field'            // 🟡 Medium
  | 'required-mismatch'      // 🟡 Medium
  | 'response-code-mismatch' // 🟢 Low
  | 'deprecated-not-removed' // 🟢 Low

Severity

typescript
type Severity = 'critical' | 'high' | 'medium' | 'low'
SeverityEmojiImpact
critical🔴Will break clients
high🔴Likely to break clients
medium🟡May cause issues
low🟢Non-breaking

Example

Missing Endpoint

typescript
const drift: DriftResult = {
  type: 'missing-endpoint',
  severity: 'critical',
  method: 'DELETE',
  path: '/users/{id}',
  message: 'Endpoint missing in code',
  details: { specLocation: { file: 'openapi.yaml', line: 45 } },
  suggestions: ['Add DELETE handler', 'Remove from spec']
}

Type Mismatch

typescript
const drift: DriftResult = {
  type: 'type-mismatch',
  severity: 'high',
  method: 'POST',
  path: '/orders',
  message: 'Field userId type mismatch',
  details: { field: 'userId', specType: 'string', codeType: 'number' },
  suggestions: ['Change code type to string', 'Update spec']
}

See Also

MIT License