University of Canterbury · API Governance Rules

University of Canterbury API Rules

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

8 Rules error 4 warn 4
View Rules File View on GitHub

Rule Categories

uc

Rules

error
uc-figshare-info-title
API info must declare a title.
$.info
error
uc-figshare-info-version
API info must declare a version.
$.info
warn
uc-figshare-server-url
At least one server URL must be defined and point at the figshare v2 base.
$.servers[*]
warn
uc-figshare-operation-tags
Every operation should carry at least one tag (figshare groups by resource, e.g. articles, collections, projects).
$.paths[*][get,post,put,delete,patch]
error
uc-figshare-operation-responses
Every operation must define responses.
$.paths[*][get,post,put,delete,patch]
warn
uc-figshare-article-id-integer
Article identifiers are integers across the figshare model.
$.components.schemas.Article.properties.id
warn
uc-figshare-doi-present
Core scholarly objects (Article, Collection) should expose a DOI for citation.
$.components.schemas.Article.properties$.components.schemas.Collection.properties
error
uc-figshare-no-http-server
Servers must use HTTPS.
$.servers[*].url

Spectral Ruleset

Raw ↑
rules:
  uc-figshare-info-title:
    description: API info must declare a title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  uc-figshare-info-version:
    description: API info must declare a version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  uc-figshare-server-url:
    description: At least one server URL must be defined and point at the figshare v2 base.
    severity: warn
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: "^https://api\\.figshare\\.com/v2"
  uc-figshare-operation-tags:
    description: Every operation should carry at least one tag (figshare groups by resource, e.g. articles, collections, projects).
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: truthy
  uc-figshare-operation-responses:
    description: Every operation must define responses.
    severity: error
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: responses
      function: truthy
  uc-figshare-article-id-integer:
    description: Article identifiers are integers across the figshare model.
    severity: warn
    given: $.components.schemas.Article.properties.id
    then:
      field: type
      function: pattern
      functionOptions:
        match: "^integer$"
  uc-figshare-doi-present:
    description: Core scholarly objects (Article, Collection) should expose a DOI for citation.
    severity: warn
    given:
      - $.components.schemas.Article.properties
      - $.components.schemas.Collection.properties
    then:
      field: doi
      function: truthy
  uc-figshare-no-http-server:
    description: Servers must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        notMatch: "^http://"