Texas Instruments · API Governance Rules

Texas Instruments API Rules

Spectral linting rules defining API design standards and conventions for Texas Instruments.

7 Rules error 2 warn 3 info 2
View Rules File View on GitHub

Rule Categories

ti

Rules

warn
ti-path-version-prefix
TI API paths should include version prefix
$.paths[*]~
error
ti-oauth2-security
All TI API operations must use OAuth2 authentication
$.paths[*][get,post,put,delete]
info
ti-part-number-param-name
Part number path parameters should be named partNumber
$.paths[*][*].parameters[?(@.in == 'path')]
warn
ti-200-response-content
Successful responses must return content
$.paths[*][get,post].responses.200
error
ti-operation-summary
All operations must have a summary
$.paths[*][get,post,put,delete]
warn
ti-tags-title-case
Tags must use Title Case
$.paths[*][*].tags[*]
info
ti-create-returns-201
POST create operations should return HTTP 201
$.paths[*].post

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # TI API: Paths must use versioned base paths
  ti-path-version-prefix:
    description: TI API paths should include version prefix
    message: Path "{{value}}" should use a versioned path (e.g., /v1/ or /v2/)
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/v[0-9]/"

  # TI API: OAuth2 must be defined for all operations
  ti-oauth2-security:
    description: All TI API operations must use OAuth2 authentication
    message: Operation must define OAuth2 security
    severity: error
    given: "$.paths[*][get,post,put,delete]"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: [security]
            - {}

  # TI API: Part number path params must use specific name
  ti-part-number-param-name:
    description: Part number path parameters should be named partNumber
    message: Part number parameter should be named "partNumber"
    severity: info
    given: "$.paths[*][*].parameters[?(@.in == 'path')]"
    then:
      function: schema
      functionOptions:
        schema:
          not:
            properties:
              name:
                enum: [part, part_number, partnumber, opn]

  # TI API: 200 responses must have content
  ti-200-response-content:
    description: Successful responses must return content
    message: Response 200 must include content definition
    severity: warn
    given: "$.paths[*][get,post].responses.200"
    then:
      field: content
      function: truthy

  # TI API: All operations must have summaries
  ti-operation-summary:
    description: All operations must have a summary
    message: Operation is missing a summary
    severity: error
    given: "$.paths[*][get,post,put,delete]"
    then:
      field: summary
      function: truthy

  # TI API: Tags must use Title Case
  ti-tags-title-case:
    description: Tags must use Title Case
    message: Tag "{{value}}" should use Title Case
    severity: warn
    given: "$.paths[*][*].tags[*]"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z]*(\\s[A-Z][a-zA-Z]*)*$"

  # TI API: POST create operations should return 201
  ti-create-returns-201:
    description: POST create operations should return HTTP 201
    message: POST operation that creates resources should return 201
    severity: info
    given: "$.paths[*].post"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            responses:
              anyOf:
                - required: ["201"]
                - required: ["200"]