Wine-Searcher · API Governance Rules

Wine-Searcher API Rules

Spectral linting rules defining API design standards and conventions for Wine-Searcher.

9 Rules error 6 warn 2 info 1
View Rules File View on GitHub

Rule Categories

wine

Rules

info
wine-searcher-get-only
Wine-Searcher API uses GET for all endpoints
$.paths[*]
error
wine-searcher-api-key-required
All Wine-Searcher API endpoints must require api_key parameter
$.paths[*].get.parameters[?(@.name=='api_key')]
error
wine-searcher-winename-required
All Wine-Searcher API endpoints must require winename parameter
$.paths[*].get.parameters[?(@.name=='winename')]
error
wine-searcher-operation-id-required
All operations must have an operationId
$.paths[*][get,post,put,delete,patch]
warn
wine-searcher-operation-id-camel-case
OperationIds should use camelCase
$.paths[*][*].operationId
error
wine-searcher-operation-tags-required
All operations must have at least one tag
$.paths[*][get,post,put,delete,patch]
error
wine-searcher-summary-required
All operations must have a summary
$.paths[*][get,post,put,delete,patch]
warn
wine-searcher-schema-descriptions
Schema components should have descriptions
$.components.schemas[*]
error
wine-searcher-success-response-required
Operations must define at least one response
$.paths[*][get,post,put,delete,patch].responses

Spectral Ruleset

Raw ↑
extends: [[spectral:oas, recommended]]

rules:
  # Wine-Searcher API uses GET for all endpoints
  wine-searcher-get-only:
    description: Wine-Searcher API uses GET for all endpoints
    message: "Wine-Searcher API endpoints should use GET method"
    severity: info
    given: "$.paths[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  # api_key must be a required query parameter
  wine-searcher-api-key-required:
    description: All Wine-Searcher API endpoints must require api_key parameter
    message: "Operation should include required 'api_key' query parameter"
    severity: error
    given: "$.paths[*].get.parameters[?(@.name=='api_key')]"
    then:
      field: required
      function: truthy

  # winename must be a required query parameter
  wine-searcher-winename-required:
    description: All Wine-Searcher API endpoints must require winename parameter
    message: "Operation should include required 'winename' query parameter"
    severity: error
    given: "$.paths[*].get.parameters[?(@.name=='winename')]"
    then:
      field: required
      function: truthy

  # Operations must have operationIds
  wine-searcher-operation-id-required:
    description: All operations must have an operationId
    message: "Operation is missing an operationId"
    severity: error
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: operationId
      function: truthy

  # OperationIds in camelCase
  wine-searcher-operation-id-camel-case:
    description: 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]+$"

  # Operations must have tags
  wine-searcher-operation-tags-required:
    description: All operations must have at least one tag
    message: "Operation is missing tags"
    severity: error
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: tags
      function: truthy

  # Summaries must be present
  wine-searcher-summary-required:
    description: All operations must have a summary
    message: "Operation is missing a summary"
    severity: error
    given: "$.paths[*][get,post,put,delete,patch]"
    then:
      field: summary
      function: truthy

  # Schemas should have descriptions
  wine-searcher-schema-descriptions:
    description: Schema components should have descriptions
    message: "Schema '{{path}}' is missing a description"
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  # Responses must be defined
  wine-searcher-success-response-required:
    description: Operations must define at least one response
    message: "Operation has no responses defined"
    severity: error
    given: "$.paths[*][get,post,put,delete,patch].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          minProperties: 1