Country.io · API Governance Rules

Country.io API Rules

Spectral linting rules defining API design standards and conventions for Country.io.

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

Rule Categories

country

Rules

error
country-io-info-title
API title must mention Country.io.
$.info.title
warn
country-io-server
Servers must reference https://country.io.
$.servers[*].url
error
country-io-paths-json
All Country.io data paths must end in .json.
$.paths
error
country-io-get-only
Country.io data endpoints must only support GET.
$.paths.*
error
country-io-operation-id
Operations must define an operationId.
$.paths.*.get
error
country-io-tags
Operations must define at least one tag.
$.paths.*.get
error
country-io-200-json-response
Each endpoint must define a 200 application/json response.
$.paths.*.get.responses.200.content

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]
documentationUrl: https://country.io/data/
rules:
  country-io-info-title:
    description: API title must mention Country.io.
    given: "$.info.title"
    severity: error
    then:
      function: pattern
      functionOptions:
        match: "Country.io"
  country-io-server:
    description: Servers must reference https://country.io.
    given: "$.servers[*].url"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "country.io"
  country-io-paths-json:
    description: All Country.io data paths must end in .json.
    given: "$.paths"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            "^/[a-z0-9_-]+\\.json$": {}
          additionalProperties: false
  country-io-get-only:
    description: Country.io data endpoints must only support GET.
    given: "$.paths.*"
    severity: error
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            get:
              type: object
          additionalProperties: false
  country-io-operation-id:
    description: Operations must define an operationId.
    given: "$.paths.*.get"
    severity: error
    then:
      field: operationId
      function: truthy
  country-io-tags:
    description: Operations must define at least one tag.
    given: "$.paths.*.get"
    severity: error
    then:
      field: tags
      function: truthy
  country-io-200-json-response:
    description: Each endpoint must define a 200 application/json response.
    given: "$.paths.*.get.responses.200.content"
    severity: error
    then:
      field: application/json
      function: truthy