AccuWeather · API Governance Rules

AccuWeather API Rules

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

24 Rules error 11 warn 10 info 3
View Rules File View on GitHub

Rule Categories

delete get info openapi operation parameter paths response schema security servers

Rules

warn
info-title-format
$.info.title
error
info-description-required
$.info
error
info-version-required
$.info
error
openapi-version-3
$
error
servers-defined
$
error
servers-https-only
$.servers[*].url
warn
paths-kebab-case
$.paths[*]~
warn
paths-no-trailing-slash
$.paths[*]~
error
operation-summary-required
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-starts-with-accuweather
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
$.paths[*][get,post,put,patch,delete]
error
operation-id-required
$.paths[*][get,post,put,patch,delete]
warn
parameter-description-required
$.paths[*][*].parameters[*]
error
parameter-schema-required
$.paths[*][*].parameters[*]
error
response-success-required
$.paths[*][get,post,put,patch,delete].responses
error
response-description-required
$.paths[*][*].responses[*]
info
response-error-401
$.paths[*][get,post,put,patch,delete].responses
info
schema-properties-described
$.components.schemas[*].properties[*]
warn
schema-type-defined
$.components.schemas[*].properties[*]
warn
security-schemes-defined
$.components
error
get-no-request-body
$.paths[*].get
warn
delete-no-request-body
$.paths[*].delete
info
operation-examples-encouraged
$.paths[*][get,post,put,patch,delete].responses[*].content[*]

Spectral Ruleset

Raw ↑
rules:
  # INFO / METADATA
  info-title-format:
    message: API title should start with "AccuWeather"
    severity: warn
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "^AccuWeather"

  info-description-required:
    message: API info must have a non-empty description
    severity: error
    given: "$.info"
    then:
      field: description
      function: truthy

  info-version-required:
    message: API info must include a version
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  # OPENAPI VERSION
  openapi-version-3:
    message: Must use OpenAPI 3.x
    severity: error
    given: "$"
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: "^3\\."

  # SERVERS
  servers-defined:
    message: At least one server must be defined
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

  servers-https-only:
    message: All server URLs must use HTTPS
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  # PATHS — NAMING CONVENTIONS
  paths-kebab-case:
    message: Path segments should use kebab-case
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9{}-]+)+$"

  paths-no-trailing-slash:
    message: Paths should not have trailing slashes
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  # OPERATIONS
  operation-summary-required:
    message: All operations must have a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  operation-summary-starts-with-accuweather:
    message: Operation summaries should start with "AccuWeather"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^AccuWeather"

  operation-description-required:
    message: All operations should have a description
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  operation-tags-required:
    message: All operations must have at least one tag
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  operation-id-required:
    message: All operations must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  # PARAMETERS
  parameter-description-required:
    message: All parameters must have a description
    severity: warn
    given: "$.paths[*][*].parameters[*]"
    then:
      field: description
      function: truthy

  parameter-schema-required:
    message: All parameters must have a schema
    severity: error
    given: "$.paths[*][*].parameters[*]"
    then:
      field: schema
      function: truthy

  # RESPONSES
  response-success-required:
    message: All operations must have at least one 2xx response
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ['200']
            - required: ['201']
            - required: ['204']

  response-description-required:
    message: All responses must have a description
    severity: error
    given: "$.paths[*][*].responses[*]"
    then:
      field: description
      function: truthy

  response-error-401:
    message: Protected operations should include a 401 response
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required: ['401']

  # SCHEMAS — PROPERTY NAMING
  schema-properties-described:
    message: Schema properties should have descriptions
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  schema-type-defined:
    message: All schema properties should have a type defined
    severity: warn
    given: "$.components.schemas[*].properties[*]"
    then:
      field: type
      function: truthy

  # SECURITY
  security-schemes-defined:
    message: Security schemes should be defined in components
    severity: warn
    given: "$.components"
    then:
      field: securitySchemes
      function: truthy

  # HTTP METHOD CONVENTIONS
  get-no-request-body:
    message: GET operations must not have a request body
    severity: error
    given: "$.paths[*].get"
    then:
      field: requestBody
      function: falsy

  delete-no-request-body:
    message: DELETE operations should not have a request body
    severity: warn
    given: "$.paths[*].delete"
    then:
      field: requestBody
      function: falsy

  # GENERAL QUALITY
  operation-examples-encouraged:
    message: Operations should include examples for mock server compatibility
    severity: info
    given: "$.paths[*][get,post,put,patch,delete].responses[*].content[*]"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ['example']
            - required: ['examples']