Whisky Hunter · API Governance Rules

Whisky Hunter API Rules

Spectral linting rules defining API design standards and conventions for Whisky Hunter.

9 Rules error 2 warn 7
View Rules File View on GitHub

Rule Categories

whisky

Rules

warn
whisky-hunter-no-auth-required
The Whisky Hunter API is public and should not declare security requirements.
$.paths.*.*
warn
whisky-hunter-trailing-slash-paths
Whisky Hunter API paths end with a trailing slash per convention.
$.paths.*~
warn
whisky-hunter-format-query-param
GET endpoints should support the format query parameter for JSON output.
$.paths.*.get
error
whisky-hunter-response-200-defined
All GET operations must define a 200 response.
$.paths.*.get
warn
whisky-hunter-array-response-for-data-endpoints
Data endpoints should return arrays.
$.paths.*.get.responses.200.content.application/json.schema
warn
whisky-hunter-operation-ids-camel-case
All operationIds should use camelCase.
$.paths.*.*.operationId
error
whisky-hunter-tags-on-operations
All operations must have at least one tag.
$.paths.*.*
warn
whisky-hunter-description-on-operations
All operations should have a description.
$.paths.*.*
warn
whisky-hunter-slug-path-param
Distillery data path must use {slug} path parameter.
$.paths[?(@property.includes('distillery_data'))].get.parameters[*]

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

  whisky-hunter-no-auth-required:
    description: The Whisky Hunter API is public and should not declare security requirements.
    message: Whisky Hunter API operations should not require authentication.
    severity: warn
    given: "$.paths.*.*"
    then:
      field: security
      function: falsy

  whisky-hunter-trailing-slash-paths:
    description: Whisky Hunter API paths end with a trailing slash per convention.
    message: Path '{{path}}' should end with a trailing slash per Whisky Hunter convention.
    severity: warn
    given: "$.paths.*~"
    then:
      function: pattern
      functionOptions:
        match: ".*/$"

  whisky-hunter-format-query-param:
    description: GET endpoints should support the format query parameter for JSON output.
    message: GET operation at '{{path}}' should document the format query parameter.
    severity: warn
    given: "$.paths.*.get"
    then:
      field: parameters
      function: truthy

  whisky-hunter-response-200-defined:
    description: All GET operations must define a 200 response.
    message: GET operation at '{{path}}' must define a 200 response.
    severity: error
    given: "$.paths.*.get"
    then:
      field: responses.200
      function: truthy

  whisky-hunter-array-response-for-data-endpoints:
    description: Data endpoints should return arrays.
    message: Data endpoint '{{path}}' should return an array in the 200 response schema.
    severity: warn
    given: "$.paths.*.get.responses.200.content.application/json.schema"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            type:
              enum:
                - array

  whisky-hunter-operation-ids-camel-case:
    description: All operationIds should use camelCase.
    message: OperationId '{{value}}' should use camelCase.
    severity: warn
    given: "$.paths.*.*.operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  whisky-hunter-tags-on-operations:
    description: All operations must have at least one tag.
    message: Operation '{{path}}' must have at least one tag.
    severity: error
    given: "$.paths.*.*"
    then:
      field: tags
      function: truthy

  whisky-hunter-description-on-operations:
    description: All operations should have a description.
    message: Operation '{{path}}' is missing a description.
    severity: warn
    given: "$.paths.*.*"
    then:
      field: description
      function: truthy

  whisky-hunter-slug-path-param:
    description: Distillery data path must use {slug} path parameter.
    message: Distillery data path should use {slug} path parameter.
    severity: warn
    given: "$.paths[?(@property.includes('distillery_data'))].get.parameters[*]"
    then:
      field: name
      function: truthy