Weatherbit · API Governance Rules

Weatherbit API Rules

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

24 Rules error 6 warn 14 info 4
View Rules File View on GitHub

Rule Categories

contact error get info no openapi operation parameter paths query response schema servers

Rules

error
info-title-required
Info must have a title
$.info
warn
info-description-required
Info must have a description
$.info
error
info-version-required
Info must have a version
$.info
error
openapi-version-3
Must use OpenAPI 3.x
$
error
servers-required
Servers array must be defined
$
warn
servers-https-only
All server URLs must use HTTPS
$.servers[*].url
info
paths-kebab-case
Path segments must use kebab-case or snake_case
$.paths[*]~
warn
paths-no-trailing-slash
Paths must not have trailing slashes
$.paths[*]~
warn
operation-summary-required
Every operation must have a summary
$.paths[*][get,post,put,delete,patch]
info
operation-summary-weatherbit-prefix
Operation summaries must start with Weatherbit
$.paths[*][get,post,put,delete,patch].summary
warn
operation-tags-required
Operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
warn
parameter-description-required
Every parameter should have a description
$.paths[*][get,post,put,delete,patch].parameters[*]
info
parameter-api-key-in-query
API key parameter must be named 'key'
$.paths[*][get,post,put,delete,patch].parameters[?(@.name == 'key')]
error
response-success-required
Every operation must have a 2xx success response
$.paths[*][get,post,put,delete,patch].responses
warn
response-description-required
Every response must have a description
$.paths[*][get,post,put,delete,patch].responses[*]
warn
schema-type-defined
Schemas should define a type
$.components.schemas[*]
error
get-no-request-body
GET operations must not have a request body
$.paths[*].get
warn
no-empty-descriptions
Descriptions must not be empty strings
$..description
info
contact-info-recommended
Info should have contact details
$.info
warn
servers-expected-domain
Server URLs should be on the weatherbit.io domain.
$.servers[*].url
warn
query-params-casing
Query parameters should be snake_case (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
warn
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
error-schema-defined
A shared error schema (Error) should be defined for error payloads.
$.components.schemas

Spectral Ruleset

Raw ↑
# weatherbit — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 50% of servers already https (warn)
#   - servers-expected-domain: 2/2 servers on weatherbit.io
#   - query-params-casing: snake @ 100% (n=149)
#   - schema-names-casing: pascal @ 100% (n=32)
#   - schema-properties-casing: snake @ 100% (n=400)
#   - error-schema-defined: Error
#   - merge: kept 19 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, query-params-casing, schema-names-casing, schema-properties-casing, error-schema-defined
extends:
  - spectral:oas
rules:
  info-title-required:
    description: Info must have a title
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-description-required:
    description: Info must have a description
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info must have a version
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    description: Must use OpenAPI 3.x
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-required:
    description: Servers array must be defined
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https-only:
    description: All server URLs must use HTTPS
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  paths-kebab-case:
    description: Path segments must use kebab-case or snake_case
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(\/[a-z0-9{}_,\-\/]*)*$
  paths-no-trailing-slash:
    description: Paths must not have trailing slashes
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: \/$
  operation-summary-required:
    description: Every operation must have a summary
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: summary
      function: truthy
  operation-summary-weatherbit-prefix:
    description: Operation summaries must start with Weatherbit
    message: 'Summary must start with ''Weatherbit'': {{value}}'
    severity: info
    given: $.paths[*][get,post,put,delete,patch].summary
    then:
      function: pattern
      functionOptions:
        match: ^Weatherbit
  operation-tags-required:
    description: Operations must have at least one tag
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: truthy
  parameter-description-required:
    description: Every parameter should have a description
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].parameters[*]
    then:
      field: description
      function: truthy
  parameter-api-key-in-query:
    description: API key parameter must be named 'key'
    message: API key parameter should be named 'key'
    severity: info
    given: $.paths[*][get,post,put,delete,patch].parameters[?(@.name == 'key')]
    then:
      field: in
      function: enumeration
      functionOptions:
        values:
        - query
  response-success-required:
    description: Every operation must have a 2xx success response
    severity: error
    given: $.paths[*][get,post,put,delete,patch].responses
    then:
      function: schema
      functionOptions:
        schema:
          minProperties: 1
  response-description-required:
    description: Every response must have a description
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].responses[*]
    then:
      field: description
      function: truthy
  schema-type-defined:
    description: Schemas should define a type
    severity: warn
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy
  get-no-request-body:
    description: GET operations must not have a request body
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  no-empty-descriptions:
    description: Descriptions must not be empty strings
    severity: warn
    given: $..description
    then:
      function: pattern
      functionOptions:
        match: .+
  contact-info-recommended:
    description: Info should have contact details
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the weatherbit.io domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: weatherbit\.io
  query-params-casing:
    description: Query parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: snake
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z0-9]*$
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  error-schema-defined:
    description: A shared error schema (Error) should be defined for error payloads.
    severity: warn
    given: $.components.schemas
    then:
      field: Error
      function: truthy