University of Basel · API Governance Rules

University of Basel API Rules

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

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

Rule Categories

basel

Rules

warn
basel-info-contact
API info should declare a contact (DSP-API declares DaSCH as contact).
$.info
error
basel-info-version-present
API info must declare a version (DSP-API uses a vNN.NN.NN scheme).
$.info
error
basel-server-https
All servers must use HTTPS (DSP-API is served over TLS only).
$.servers[*].url
warn
basel-operation-tags
Every operation should be tagged (DSP-API groups by Admin/Management/API v2/API v3/Ontology Mappings).
$.paths[*][get,put,post,delete,patch]
warn
basel-operation-description
Operations should carry a human description (DSP-API documents each endpoint).
$.paths[*][get,put,post,delete,patch]
info
basel-known-tags
Tags should come from the DSP-API tag vocabulary.
$.paths[*][get,put,post,delete,patch].tags[*]
info
basel-error-response
Operations should document at least one non-2xx response (DSP-API returns typed error bodies).
$.paths[*][get,put,post,delete,patch].responses

Spectral Ruleset

university-of-basel-rules.yml Raw ↑
# Spectral ruleset for the University of Basel / DaSCH DSP-API.
# Encodes patterns observed in the live OpenAPI 3.1 description published at
# https://api.dasch.swiss/api/docs/docs.yaml (DSP-API v35.10.0).
formats:
  - oas3
rules:
  basel-info-contact:
    description: API info should declare a contact (DSP-API declares DaSCH as contact).
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  basel-info-version-present:
    description: API info must declare a version (DSP-API uses a vNN.NN.NN scheme).
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  basel-server-https:
    description: All servers must use HTTPS (DSP-API is served over TLS only).
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://"
  basel-operation-tags:
    description: Every operation should be tagged (DSP-API groups by Admin/Management/API v2/API v3/Ontology Mappings).
    severity: warn
    given: $.paths[*][get,put,post,delete,patch]
    then:
      field: tags
      function: truthy
  basel-operation-description:
    description: Operations should carry a human description (DSP-API documents each endpoint).
    severity: warn
    given: $.paths[*][get,put,post,delete,patch]
    then:
      field: description
      function: truthy
  basel-known-tags:
    description: Tags should come from the DSP-API tag vocabulary.
    severity: info
    given: $.paths[*][get,put,post,delete,patch].tags[*]
    then:
      function: enumeration
      functionOptions:
        values:
          - Admin API
          - Management API
          - API v2
          - API v3
          - Ontology Mappings
  basel-error-response:
    description: Operations should document at least one non-2xx response (DSP-API returns typed error bodies).
    severity: info
    given: $.paths[*][get,put,post,delete,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1