TEGNA · API Governance Rules

TEGNA API Rules

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

10 Rules error 3 warn 6
View Rules File View on GitHub

Rule Categories

tegna

Rules

warn
tegna-operation-ids-camel-case
Operation IDs must use camelCase naming convention.
$.paths[*][*].operationId
error
tegna-operations-have-summaries
All operations must have a summary.
$.paths[*][*]
warn
tegna-title-case-summaries
Operation summaries must use Title Case.
$.paths[*][*].summary
warn
tegna-operations-have-tags
All operations must be tagged.
$.paths[*][*]
error
tegna-responses-have-descriptions
All responses must have descriptions.
$.paths[*][*].responses[*]
warn
tegna-security-defined
All operations must define security requirements.
$.paths[*][*]
error
tegna-servers-defined
API must define at least one server.
$
warn
tegna-components-schemas
API must define reusable schemas.
$.components
hint
tegna-campaign-status-enum
Campaign status fields should use the standard enum values.
$.components.schemas.Campaign.properties.status
warn
tegna-date-formats
Date fields should use ISO 8601 format.
$.components.schemas[*].properties[?(@.type === 'string')]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

rules:
  tegna-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]*$"

  tegna-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

  tegna-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 ]*$"

  tegna-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

  tegna-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

  tegna-security-defined:
    description: All operations must define security requirements.
    message: "Operation must include a security definition."
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: security
      function: truthy

  tegna-servers-defined:
    description: API must define at least one server.
    message: "API must include a servers array."
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  tegna-components-schemas:
    description: API must define reusable schemas.
    message: "API should define schemas in components/schemas."
    severity: warn
    given: "$.components"
    then:
      field: schemas
      function: truthy

  tegna-campaign-status-enum:
    description: Campaign status fields should use the standard enum values.
    message: "Campaign status should be one of: active, paused, completed, draft."
    severity: hint
    given: "$.components.schemas.Campaign.properties.status"
    then:
      field: enum
      function: truthy

  tegna-date-formats:
    description: Date fields should use ISO 8601 format.
    message: "Date field should use format: date or date-time."
    severity: warn
    given: "$.components.schemas[*].properties[?(@.type === 'string')]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object