Democracy Works · API Governance Rules

Democracy Works API Rules

Spectral linting rules defining API design standards and conventions for Democracy Works.

6 Rules error 1 warn 5
View Rules File View on GitHub

Rule Categories

democracy

Rules

warn
democracy-works-info-contact
API info should include a contact for Democracy Works.
$.info
warn
democracy-works-base-url
Servers should reference api.democracy.works.
$.servers[*].url
error
democracy-works-apikey-auth
API should declare X-API-Key authentication.
$.components.securitySchemes
warn
democracy-works-elections-resource
API should expose /elections as a primary resource.
$.paths
warn
democracy-works-authorities-resource
API should expose /authorities as a primary resource.
$.paths
warn
democracy-works-operation-tags
Operations should be tagged Elections, Authorities, etc.
$.paths[*][*]

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas
rules:
  democracy-works-info-contact:
    description: API info should include a contact for Democracy Works.
    given: $.info
    severity: warn
    then:
      field: contact
      function: truthy
  democracy-works-base-url:
    description: Servers should reference api.democracy.works.
    given: $.servers[*].url
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "democracy\\.works"
  democracy-works-apikey-auth:
    description: API should declare X-API-Key authentication.
    given: $.components.securitySchemes
    severity: error
    then:
      field: ApiKeyAuth
      function: truthy
  democracy-works-elections-resource:
    description: API should expose /elections as a primary resource.
    given: $.paths
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "/elections"
  democracy-works-authorities-resource:
    description: API should expose /authorities as a primary resource.
    given: $.paths
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "/authorities"
  democracy-works-operation-tags:
    description: Operations should be tagged Elections, Authorities, etc.
    given: $.paths[*][*]
    severity: warn
    then:
      field: tags
      function: truthy