Tyson Foods · API Governance Rules

Tyson Foods API Rules

Spectral linting rules defining API design standards and conventions for Tyson Foods.

8 Rules error 2 warn 5
View Rules File View on GitHub

Rule Categories

tyson

Rules

warn
tyson-foods-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
tyson-foods-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
tyson-foods-auth-required
All Tyson Foods API operations should require authentication
$.paths[*][get,post,put,patch,delete]
warn
tyson-foods-operation-description
All operations should have a description
$.paths[*][get,post,put,patch,delete]
hint
tyson-foods-path-param-description
Path parameters should have descriptions
$.paths[*][*].parameters[?(@.in == 'path')]
error
tyson-foods-success-response
Operations must define a success response
$.paths[*][get,post,put,patch,delete].responses
warn
tyson-foods-tags-title-case
Tags must use Title Case
$.tags[*].name
error
tyson-foods-server-https
API servers should use HTTPS
$.servers[*].url

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

  # All summaries must use Title Case
  tyson-foods-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' must use Title Case"
    given: "$.paths[*][*].summary"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  # Operation IDs must use camelCase
  tyson-foods-operation-id-camel-case:
    description: Operation IDs must use camelCase
    message: "OperationId '{{value}}' must use camelCase"
    given: "$.paths[*][*].operationId"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  # All operations should have authentication
  tyson-foods-auth-required:
    description: All Tyson Foods API operations should require authentication
    message: "Operation should declare authentication security"
    given: "$.paths[*][get,post,put,patch,delete]"
    severity: warn
    then:
      field: security
      function: truthy

  # All operations should have descriptions
  tyson-foods-operation-description:
    description: All operations should have a description
    message: "Operation '{{path}}' is missing a description"
    given: "$.paths[*][get,post,put,patch,delete]"
    severity: warn
    then:
      field: description
      function: truthy

  # Path parameters should have descriptions
  tyson-foods-path-param-description:
    description: Path parameters should have descriptions
    message: "Path parameter '{{value}}' is missing description"
    given: "$.paths[*][*].parameters[?(@.in == 'path')]"
    severity: hint
    then:
      field: description
      function: truthy

  # Successful responses must be defined
  tyson-foods-success-response:
    description: Operations must define a success response
    message: "Operation must define a 200 or 201 response"
    given: "$.paths[*][get,post,put,patch,delete].responses"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["200"]
            - required: ["201"]
            - required: ["204"]

  # Tags should use Title Case
  tyson-foods-tags-title-case:
    description: Tags must use Title Case
    message: "Tag '{{value}}' must use Title Case"
    given: "$.tags[*].name"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z ]+$"

  # Server URLs should use HTTPS
  tyson-foods-server-https:
    description: API servers should use HTTPS
    message: "Server URL '{{value}}' should use HTTPS"
    given: "$.servers[*].url"
    severity: error
    then:
      function: pattern
      functionOptions:
        match: "^https://"