Telefónica · API Governance Rules

Telefónica API Rules

Spectral linting rules defining API design standards and conventions for Telefónica.

11 Rules error 5 warn 6
View Rules File View on GitHub

Rule Categories

telefonica

Rules

warn
telefonica-operation-ids-camel-case
Operation IDs must use camelCase naming convention.
$.paths[*][*].operationId
error
telefonica-operations-have-summaries
All operations must have a summary.
$.paths[*][*]
warn
telefonica-title-case-summaries
Operation summaries must use Title Case.
$.paths[*][*].summary
warn
telefonica-operations-have-tags
All operations must be tagged.
$.paths[*][*]
error
telefonica-responses-have-descriptions
All responses must have descriptions.
$.paths[*][*].responses[*]
warn
telefonica-openid-security-scheme
Telefónica Open Gateway APIs must use OpenID Connect authentication.
$.components.securitySchemes[*]
warn
telefonica-phone-number-e164-pattern
Phone number fields must use E.164 format pattern.
$.components.schemas[*].properties.phoneNumber
error
telefonica-error-response-schema
Error responses must define a schema.
$.paths[*][*].responses[4*].content.application/json
error
telefonica-servers-defined
API must define production and sandbox servers.
$
error
telefonica-camara-version
CAMARA APIs should include version information in info.
$.info
warn
telefonica-license-defined
Open Gateway APIs must include license information.
$.info

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:
  telefonica-operation-ids-camel-case:
    description: Operation IDs must use camelCase naming convention.
    message: "Operation ID '{{value}}' must use camelCase."
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  telefonica-operations-have-summaries:
    description: All operations must have a summary.
    message: "Operation must include a summary."
    severity: error
    given: "$.paths[*][*]"
    then:
      field: summary
      function: truthy

  telefonica-title-case-summaries:
    description: Operation summaries must use Title Case.
    message: "Summary '{{value}}' should use Title Case."
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  telefonica-operations-have-tags:
    description: All operations must be tagged.
    message: "Operation must have at least one tag."
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  telefonica-responses-have-descriptions:
    description: All responses must have descriptions.
    message: "Response must include a description."
    severity: error
    given: "$.paths[*][*].responses[*]"
    then:
      field: description
      function: truthy

  telefonica-openid-security-scheme:
    description: Telefónica Open Gateway APIs must use OpenID Connect authentication.
    message: "Security scheme should use OpenID Connect."
    severity: warn
    given: "$.components.securitySchemes[*]"
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - openIdConnect

  telefonica-phone-number-e164-pattern:
    description: Phone number fields must use E.164 format pattern.
    message: "Phone number field should define E.164 pattern validation."
    severity: warn
    given: "$.components.schemas[*].properties.phoneNumber"
    then:
      field: pattern
      function: truthy

  telefonica-error-response-schema:
    description: Error responses must define a schema.
    message: "Error response must include a schema."
    severity: error
    given: "$.paths[*][*].responses[4*].content.application/json"
    then:
      field: schema
      function: truthy

  telefonica-servers-defined:
    description: API must define production and sandbox servers.
    message: "API must include a servers array."
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  telefonica-camara-version:
    description: CAMARA APIs should include version information in info.
    message: "API must define a version in info.version."
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  telefonica-license-defined:
    description: Open Gateway APIs must include license information.
    message: "API must define license information."
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy