Hamad Bin Khalifa University · API Governance Rules

Hamad Bin Khalifa University API Rules

Spectral linting rules defining API design standards and conventions for Hamad Bin Khalifa University.

7 Rules error 2 warn 4 info 1
View Rules File View on GitHub

Rule Categories

hbku

Rules

error
hbku-info-title-present
API document must declare an info.title.
$.info
error
hbku-info-version-present
API document must declare an info.version.
$.info
warn
hbku-server-is-figshare-v2
The production server should be the Figshare API v2 base URL.
$.servers[*].url
warn
hbku-operations-have-operationid
Every operation should declare an operationId.
$.paths[*][get,post,put,delete,patch]
warn
hbku-operations-have-tags
Operations should be grouped with at least one tag.
$.paths[*][get,post,put,delete,patch]
info
hbku-uses-oauth2-security
Write/private operations rely on the OAuth2 security scheme.
$.components.securitySchemes
warn
hbku-article-has-doi
The Article schema should expose a DOI property for citation.
$.components.schemas.Article.properties

Spectral Ruleset

Raw ↑
---
# Spectral ruleset for the Figshare API v2 as cataloged for HBKU (Manara - Qatar
# Research Repository). Encodes patterns observed in the real OpenAPI 3.0.3 spec
# downloaded from https://docs.figshare.com/swagger.json
extends: [[spectral:oas, off]]
formats:
  - oas3
rules:
  hbku-info-title-present:
    description: API document must declare an info.title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy

  hbku-info-version-present:
    description: API document must declare an info.version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy

  hbku-server-is-figshare-v2:
    description: The production server should be the Figshare API v2 base URL.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://api\\.figshare\\.com/v2"

  hbku-operations-have-operationid:
    description: Every operation should declare an operationId.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: operationId
      function: truthy

  hbku-operations-have-tags:
    description: Operations should be grouped with at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: truthy

  hbku-uses-oauth2-security:
    description: Write/private operations rely on the OAuth2 security scheme.
    severity: info
    given: $.components.securitySchemes
    then:
      field: OAuth2
      function: truthy

  hbku-article-has-doi:
    description: The Article schema should expose a DOI property for citation.
    severity: warn
    given: $.components.schemas.Article.properties
    then:
      field: doi
      function: truthy