University of Cape Town · API Governance Rules

University of Cape Town API Rules

Spectral linting rules defining API design standards and conventions for University of Cape Town.

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

Rule Categories

uct

Rules

warn
uct-info-contact
API info object should include a contact.
$.info
warn
uct-info-description
API info object should include a description.
$.info
error
uct-https-servers
All servers must use HTTPS (UCT public APIs are HTTPS-only).
$.servers[*].url
error
uct-operation-operationid
Every operation must declare an operationId.
$.paths[*][get,post,put,patch,delete]
warn
uct-operation-summary
Every operation should have a summary.
$.paths[*][get,post,put,patch,delete]
warn
uct-operation-tags
Every operation should be tagged.
$.paths[*][get,post,put,patch,delete]
warn
uct-resource-has-id
Catalog and repository objects expose a stable integer id.
$.components.schemas[?(@property.match(/Article$|Study$|Collection$|Project$/))].properties
warn
uct-doi-as-string
DOI fields should be modeled as strings.
$.components.schemas[*].properties.doi

Spectral Ruleset

university-of-cape-town-rules.yml Raw ↑
formats: [oas3]
rules:
  uct-info-contact:
    description: API info object should include a contact.
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  uct-info-description:
    description: API info object should include a description.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  uct-https-servers:
    description: All servers must use HTTPS (UCT public APIs are HTTPS-only).
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: '^https://'
  uct-operation-operationid:
    description: Every operation must declare an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  uct-operation-summary:
    description: Every operation should have a summary.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  uct-operation-tags:
    description: Every operation should be tagged.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  uct-resource-has-id:
    description: Catalog and repository objects expose a stable integer id.
    severity: warn
    given: $.components.schemas[?(@property.match(/Article$|Study$|Collection$|Project$/))].properties
    then:
      field: id
      function: truthy
  uct-doi-as-string:
    description: DOI fields should be modeled as strings.
    severity: warn
    given: $.components.schemas[*].properties.doi
    then:
      field: type
      function: defined