Telefonie · API Governance Rules

Telefonie API Rules

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

12 Rules error 4 warn 4 info 4
View Rules File View on GitHub

Rule Categories

telefonie

Rules

warn
telefonie-operation-summary-title-case
All operation summaries must use Title Case
$.paths[*][*].summary
error
telefonie-operation-must-have-operationid
All operations must have an operationId
$.paths[*][*]
warn
telefonie-operationid-camelcase
Operation IDs must use camelCase
$.paths[*][*].operationId
info
telefonie-operation-must-have-description
All operations should have a description
$.paths[*][*]
warn
telefonie-operation-must-have-tag
All operations must have at least one tag
$.paths[*][*]
info
telefonie-phone-number-e164
Phone number parameters should reference E.164 format in their descriptions
$.paths[*][*].parameters[?(@.name == 'to' || @.name == 'from' || @.name == 'phone_number')]
error
telefonie-response-200-required
GET and POST operations must define a 200 or 201 response
$.paths[*].get.responses
warn
telefonie-delete-204-response
DELETE operations should return 204
$.paths[*].delete.responses
info
telefonie-schema-properties-have-description
Schema properties should have descriptions
$.components.schemas[*].properties[*]
info
telefonie-pagination-parameters
List endpoints should support page and page_size parameters
$.paths[*].get.operationId
error
telefonie-security-required
All operations must have security defined
$.paths[*][*]
error
telefonie-servers-required
API must define servers
$

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  telefonie-operation-summary-title-case:
    description: All operation summaries must use Title Case
    message: "Operation summary '{{value}}' must use Title Case"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-z0-9]*([ ][A-Z][a-z0-9]*)*|[A-Z]+)$"

  telefonie-operation-must-have-operationid:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  telefonie-operationid-camelcase:
    description: Operation IDs must use camelCase
    message: "OperationId '{{value}}' must use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  telefonie-operation-must-have-description:
    description: All operations should have a description
    severity: info
    given: "$.paths[*][*]"
    then:
      field: description
      function: truthy

  telefonie-operation-must-have-tag:
    description: All operations must have at least one tag
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  telefonie-phone-number-e164:
    description: Phone number parameters should reference E.164 format in their descriptions
    message: "Phone number parameter '{{path}}' description should mention E.164 format"
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'to' || @.name == 'from' || @.name == 'phone_number')]"
    then:
      field: description
      function: truthy

  telefonie-response-200-required:
    description: GET and POST operations must define a 200 or 201 response
    severity: error
    given: "$.paths[*].get.responses"
    then:
      field: "200"
      function: truthy

  telefonie-delete-204-response:
    description: DELETE operations should return 204
    severity: warn
    given: "$.paths[*].delete.responses"
    then:
      field: "204"
      function: truthy

  telefonie-schema-properties-have-description:
    description: Schema properties should have descriptions
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  telefonie-pagination-parameters:
    description: List endpoints should support page and page_size parameters
    severity: info
    given: "$.paths[*].get.operationId"
    then:
      function: pattern
      functionOptions:
        notMatch: "^list"

  telefonie-security-required:
    description: All operations must have security defined
    severity: error
    given: "$.paths[*][*]"
    then:
      field: security
      function: falsy

  telefonie-servers-required:
    description: API must define servers
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy