TheSportsDB · API Governance Rules

TheSportsDB API Rules

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

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

Rule Categories

thesportsdb

Rules

warn
thesportsdb-operation-summary-title-case
All operation summaries must use Title Case.
$.paths[*][*].summary
warn
thesportsdb-operation-ids-camel-case
All operationIds must use camelCase.
$.paths[*][*].operationId
error
thesportsdb-tags-required
All operations must have at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
thesportsdb-description-required
All operations must have a description.
$.paths[*][get,post,put,patch,delete]
info
thesportsdb-php-path-suffix
TheSportsDB API paths end in .php per v1 convention.
$.paths[*]~
error
thesportsdb-200-response-required
All GET operations must define a 200 response.
$.paths[*][get].responses
warn
thesportsdb-query-params-for-search
Search operations should have at least one query parameter.
$.paths[?(@~'search|lookup')][get]
warn
thesportsdb-response-schema-json
All 200 responses must define a content schema.
$.paths[*][get].responses[200].content

Spectral Ruleset

Raw ↑
rules:
  thesportsdb-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-zA-Z0-9 ]*$"

  thesportsdb-operation-ids-camel-case:
    description: All operationIds must use camelCase.
    message: "OperationId '{{value}}' must be camelCase."
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  thesportsdb-tags-required:
    description: All operations must have at least one tag.
    message: "Operation at '{{path}}' must have at least one tag."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  thesportsdb-description-required:
    description: All operations must have a description.
    message: "Operation at '{{path}}' is missing a description."
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  thesportsdb-php-path-suffix:
    description: TheSportsDB API paths end in .php per v1 convention.
    message: "Path '{{path}}' should end with .php per TheSportsDB v1 convention."
    severity: info
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "\\.php$"

  thesportsdb-200-response-required:
    description: All GET operations must define a 200 response.
    message: "GET operation at '{{path}}' must define a 200 response."
    severity: error
    given: "$.paths[*][get].responses"
    then:
      field: "200"
      function: defined

  thesportsdb-query-params-for-search:
    description: Search operations should have at least one query parameter.
    message: "Search operation at '{{path}}' must have at least one filter parameter."
    severity: warn
    given: "$.paths[?(@~'search|lookup')][get]"
    then:
      field: parameters
      function: truthy

  thesportsdb-response-schema-json:
    description: All 200 responses must define a content schema.
    message: "Response at '{{path}}' must define a content schema."
    severity: warn
    given: "$.paths[*][get].responses[200].content"
    then:
      function: truthy