Erasmus University Rotterdam · API Governance Rules

Erasmus University Rotterdam API Rules

Spectral linting rules defining API design standards and conventions for Erasmus University Rotterdam.

6 Rules error 2 warn 3 info 1
View Rules File View on GitHub

Rule Categories

eur

Rules

error
eur-figshare-server-defined
The API must declare the Figshare v2 base server URL.
$.servers
warn
eur-figshare-operation-tags
Every operation should be tagged (Figshare groups by articles, collections, projects, etc.).
$.paths[*][get,post,put,delete,patch]
error
eur-figshare-operation-responses
Every operation must define at least one response.
$.paths[*][get,post,put,delete,patch].responses
warn
eur-figshare-core-object-has-id
Core resource schemas (Article, Collection, Project, Author) expose an integer id.
$.components.schemas[Article,Collection,Project,Author].properties.id
warn
eur-figshare-doi-is-string
DOI fields are represented as strings.
$.components.schemas[*].properties.doi
info
eur-figshare-url-fields-format
URL-bearing fields should declare a url/uri format.
$.components.schemas[*].properties[url,figshare_url,thumb]

Spectral Ruleset

Raw ↑
---
# Spectral ruleset for the EUR Research Data Repository (Figshare API v2)
# Encodes patterns observed in the published Figshare OpenAPI 3.0.3 description
# (https://docs.figshare.com/swagger.json), the spec backing
# https://datarepository.eur.nl/ via https://api.figshare.com/v2.
formats:
  - oas3
rules:
  eur-figshare-server-defined:
    description: The API must declare the Figshare v2 base server URL.
    severity: error
    given: $.servers
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  eur-figshare-operation-tags:
    description: Every operation should be tagged (Figshare groups by articles, collections, projects, etc.).
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: truthy

  eur-figshare-operation-responses:
    description: Every operation must define at least one response.
    severity: error
    given: $.paths[*][get,post,put,delete,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1

  eur-figshare-core-object-has-id:
    description: Core resource schemas (Article, Collection, Project, Author) expose an integer id.
    severity: warn
    given: $.components.schemas[Article,Collection,Project,Author].properties.id
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - integer

  eur-figshare-doi-is-string:
    description: DOI fields are represented as strings.
    severity: warn
    given: $.components.schemas[*].properties.doi
    then:
      field: type
      function: enumeration
      functionOptions:
        values:
          - string

  eur-figshare-url-fields-format:
    description: URL-bearing fields should declare a url/uri format.
    severity: info
    given: $.components.schemas[*].properties[url,figshare_url,thumb]
    then:
      field: format
      function: truthy