PlaceKitten · API Governance Rules

PlaceKitten API Rules

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

6 Rules error 3 warn 3
View Rules File View on GitHub

Rule Categories

placekitten

Rules

error
placekitten-path-shape
PlaceKitten paths must include {width} and {height} path parameters.
$.paths[*]
error
placekitten-width-parameter
width path parameter must be a positive integer in pixels.
$..parameters[?(@.name=='width')]
error
placekitten-height-parameter
height path parameter must be a positive integer in pixels.
$..parameters[?(@.name=='height')]
warn
placekitten-image-response
Successful responses must return image/jpeg payloads.
$.paths[*].get.responses['200'].content
warn
placekitten-operation-summary-title-case
Operation summaries should use Title Case.
$.paths[*][get,put,post,delete,patch,options,head].summary
warn
placekitten-deprecation-notice
The info block must carry x-status and x-deprecation-notice while the service is offline.
$.info

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas
rules:
  # PlaceKitten URL contract is: /{width}/{height} for color, /g/{width}/{height} for grayscale.
  # Width and height path parameters must remain positive integers.
  placekitten-path-shape:
    description: PlaceKitten paths must include {width} and {height} path parameters.
    severity: error
    given: $.paths[*]
    then:
      function: schema
      functionOptions:
        schema:
          type: object
    formats:
      - oas3
  placekitten-width-parameter:
    description: width path parameter must be a positive integer in pixels.
    severity: error
    given: $..parameters[?(@.name=='width')]
    then:
      - field: schema.type
        function: enumeration
        functionOptions:
          values: [integer]
      - field: schema.minimum
        function: truthy
  placekitten-height-parameter:
    description: height path parameter must be a positive integer in pixels.
    severity: error
    given: $..parameters[?(@.name=='height')]
    then:
      - field: schema.type
        function: enumeration
        functionOptions:
          values: [integer]
      - field: schema.minimum
        function: truthy
  placekitten-image-response:
    description: Successful responses must return image/jpeg payloads.
    severity: warn
    given: $.paths[*].get.responses['200'].content
    then:
      field: image/jpeg
      function: truthy
  placekitten-operation-summary-title-case:
    description: Operation summaries should use Title Case.
    severity: warn
    given: $.paths[*][get,put,post,delete,patch,options,head].summary
    then:
      function: pattern
      functionOptions:
        match: '^([A-Z][A-Za-z0-9]*)(\s[A-Z][A-Za-z0-9]*)*$'
  placekitten-deprecation-notice:
    description: The info block must carry x-status and x-deprecation-notice while the service is offline.
    severity: warn
    given: $.info
    then:
      - field: x-status
        function: truthy
      - field: x-deprecation-notice
        function: truthy