University of Rochester · API Governance Rules

University of Rochester API Rules

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

5 Rules warn 4 info 1
View Rules File View on GitHub

Rule Categories

urrr

Rules

warn
urrr-server-is-figshare-v2
Servers should target the Figshare v2 API base URL.
$.servers[*].url
info
urrr-public-get-no-auth
Public GET endpoints (articles, collections, projects) should be openly readable.
$.paths[?(@property.match(/^\/(articles|collections|projects)/))].get
warn
urrr-article-has-doi
The Article schema must define id, doi and url fields.
$.components.schemas.Article.properties
warn
urrr-collection-has-doi
The Collection schema must define id, doi and title fields.
$.components.schemas.Collection.properties
warn
urrr-oauth2-defined
An OAuth2 security scheme should be defined for account/write operations.
$.components.securitySchemes

Spectral Ruleset

Raw ↑
---
# Spectral ruleset for the University of Rochester Research Repository (URRR) Figshare API.
# Encodes patterns observed in the real Figshare OpenAPI 3.0.3 description
# (https://docs.figshare.com/swagger.json) as used by rochester.figshare.com.
formats:
  - oas3
extends:
  - spectral:oas
rules:
  # The API is served from the versioned Figshare base path.
  urrr-server-is-figshare-v2:
    description: Servers should target the Figshare v2 API base URL.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://api\\.figshare\\.com/v2"

  # Public read operations on articles/collections should not require security.
  urrr-public-get-no-auth:
    description: Public GET endpoints (articles, collections, projects) should be openly readable.
    severity: info
    given: $.paths[?(@property.match(/^\/(articles|collections|projects)/))].get
    then:
      field: operationId
      function: truthy

  # Core resource objects expose stable identifiers and DOIs.
  urrr-article-has-doi:
    description: The Article schema must define id, doi and url fields.
    severity: warn
    given: $.components.schemas.Article.properties
    then:
      - field: id
        function: truthy
      - field: doi
        function: truthy
      - field: url
        function: truthy

  # Timeline date fields are present on cataloged research outputs.
  urrr-collection-has-doi:
    description: The Collection schema must define id, doi and title fields.
    severity: warn
    given: $.components.schemas.Collection.properties
    then:
      - field: id
        function: truthy
      - field: doi
        function: truthy
      - field: title
        function: truthy

  # Authenticated write operations use OAuth2.
  urrr-oauth2-defined:
    description: An OAuth2 security scheme should be defined for account/write operations.
    severity: warn
    given: $.components.securitySchemes
    then:
      field: OAuth2
      function: truthy