OpenWeatherMap · API Governance Rules

OpenWeatherMap API Rules

Spectral linting rules defining API design standards and conventions for OpenWeatherMap.

11 Rules error 1 warn 10
View Rules File View on GitHub

Rule Categories

openweathermap

Rules

warn
openweathermap-summary-required
Every operation must have a summary in Title Case.
$.paths.*[get,post,put,delete,patch]
warn
openweathermap-summary-title-case
Operation summaries should use Title Case (each major word capitalized).
$.paths.*[get,post,put,delete,patch].summary
warn
openweathermap-description-required
Every operation must have a description.
$.paths.*[get,post,put,delete,patch]
error
openweathermap-operationid-required
Every operation must have an operationId.
$.paths.*[get,post,put,delete,patch]
warn
openweathermap-operationid-camelcase
operationId values should be camelCase.
$.paths.*[get,post,put,delete,patch].operationId
warn
openweathermap-tags-required
Every operation must declare at least one tag.
$.paths.*[get,post,put,delete,patch]
warn
openweathermap-appid-required
Every operation must accept an appid query parameter for API key auth.
$.paths[*][get,post,put,delete,patch].parameters[?(@.name=='appid')]
warn
openweathermap-coord-lat-lon-required
Weather endpoints should accept lat and lon parameters.
$.paths['/weather','/forecast','/forecast/hourly','/forecast/daily','/forecast/climate','/air_pollution','/air_pollution/forecast','/air_pollution/history','/current','/timeline/1min','/timeline/15min','/timeline/1h','/timeline/1day'].get.parameters[*].name
warn
openweathermap-units-enum
The units parameter must be one of standard, metric, or imperial.
$.paths.*[get,post].parameters[?(@.name=='units')]
warn
openweathermap-security-appid
Specs should declare an appid apiKey security scheme.
$.components.securitySchemes
warn
openweathermap-error-responses
Operations should document 400, 401, and 429 error responses.
$.paths.*[get,post,put,delete,patch].responses

Spectral Ruleset

Raw ↑
extends: spectral:oas
functionsDir: ./functions
documentationUrl: https://openweathermap.org/api
rules:
  openweathermap-summary-required:
    description: Every operation must have a summary in Title Case.
    given: $.paths.*[get,post,put,delete,patch]
    severity: warn
    then:
      field: summary
      function: truthy
  openweathermap-summary-title-case:
    description: Operation summaries should use Title Case (each major word capitalized).
    given: $.paths.*[get,post,put,delete,patch].summary
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: '^([A-Z][a-zA-Z0-9]*)( ([A-Z][a-zA-Z0-9]*|For|And|To|By|Of|The|A|An|In|On|With|From|Or|Per))*$'
  openweathermap-description-required:
    description: Every operation must have a description.
    given: $.paths.*[get,post,put,delete,patch]
    severity: warn
    then:
      field: description
      function: truthy
  openweathermap-operationid-required:
    description: Every operation must have an operationId.
    given: $.paths.*[get,post,put,delete,patch]
    severity: error
    then:
      field: operationId
      function: truthy
  openweathermap-operationid-camelcase:
    description: operationId values should be camelCase.
    given: $.paths.*[get,post,put,delete,patch].operationId
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]*$'
  openweathermap-tags-required:
    description: Every operation must declare at least one tag.
    given: $.paths.*[get,post,put,delete,patch]
    severity: warn
    then:
      field: tags
      function: truthy
  openweathermap-appid-required:
    description: Every operation must accept an appid query parameter for API key auth.
    given: $.paths[*][get,post,put,delete,patch].parameters[?(@.name=='appid')]
    severity: warn
    then:
      function: truthy
  openweathermap-coord-lat-lon-required:
    description: Weather endpoints should accept lat and lon parameters.
    given: "$.paths['/weather','/forecast','/forecast/hourly','/forecast/daily','/forecast/climate','/air_pollution','/air_pollution/forecast','/air_pollution/history','/current','/timeline/1min','/timeline/15min','/timeline/1h','/timeline/1day'].get.parameters[*].name"
    severity: warn
    then:
      function: enumeration
      functionOptions:
        values:
          - lat
          - lon
          - appid
          - mode
          - units
          - lang
          - cnt
          - exclude
          - start
          - end
          - dt
          - q
          - limit
          - zip
          - month
          - day
          - threshold
          - type
          - from
          - to
          - station_id
          - date
          - interval
          - tz
          - alert_id
          - location_id
          - panel_id
  openweathermap-units-enum:
    description: The units parameter must be one of standard, metric, or imperial.
    given: $.paths.*[get,post].parameters[?(@.name=='units')]
    severity: warn
    then:
      field: schema.enum
      function: truthy
  openweathermap-security-appid:
    description: Specs should declare an appid apiKey security scheme.
    given: $.components.securitySchemes
    severity: warn
    then:
      field: appid
      function: truthy
  openweathermap-error-responses:
    description: Operations should document 400, 401, and 429 error responses.
    given: $.paths.*[get,post,put,delete,patch].responses
    severity: warn
    then:
      field: '429'
      function: truthy