Country State City API · API Governance Rules

Country State City API API Rules

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

7 Rules error 4 warn 3
View Rules File View on GitHub

Rule Categories

csc

Rules

error
csc-info-title
API title must mention Country State City.
$.info.title
warn
csc-server-base-url
Servers must reference https://api.countrystatecity.in/v1.
$.servers[*].url
error
csc-api-key-security
Spec must define an X-CSCAPI-KEY API key security scheme.
$.components.securitySchemes
warn
csc-global-security
API must apply the API key security globally.
$
error
csc-operation-id
Every operation must define an operationId.
$.paths.*.get
error
csc-operation-tags
Every operation must define at least one tag.
$.paths.*.get
warn
csc-401-response
All authenticated operations should document a 401 response.
$.paths.*.get.responses

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]
documentationUrl: https://docs.countrystatecity.in/api/introduction
rules:
  csc-info-title:
    description: API title must mention Country State City.
    given: "$.info.title"
    severity: error
    then:
      function: pattern
      functionOptions:
        match: "Country State City"
  csc-server-base-url:
    description: Servers must reference https://api.countrystatecity.in/v1.
    given: "$.servers[*].url"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "api.countrystatecity.in"
  csc-api-key-security:
    description: Spec must define an X-CSCAPI-KEY API key security scheme.
    given: "$.components.securitySchemes"
    severity: error
    then:
      field: ApiKeyAuth
      function: truthy
  csc-global-security:
    description: API must apply the API key security globally.
    given: "$"
    severity: warn
    then:
      field: security
      function: truthy
  csc-operation-id:
    description: Every operation must define an operationId.
    given: "$.paths.*.get"
    severity: error
    then:
      field: operationId
      function: truthy
  csc-operation-tags:
    description: Every operation must define at least one tag.
    given: "$.paths.*.get"
    severity: error
    then:
      field: tags
      function: truthy
  csc-401-response:
    description: All authenticated operations should document a 401 response.
    given: "$.paths.*.get.responses"
    severity: warn
    then:
      field: '401'
      function: truthy