Zestful · API Governance Rules

Zestful API Rules

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

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

Rule Categories

zestful

Rules

warn
zestful-operation-id-camel-case
Operation IDs must use camelCase (Zestful convention)
$.paths[*][*].operationId
error
zestful-request-body-required
POST endpoints must define a required request body
$.paths[*].post
warn
zestful-ingredients-array-limits
Ingredients array must enforce min/maxItems limits
$.paths[*].post.requestBody.content.application/json.schema.properties.ingredients
error
zestful-response-200-defined
All operations must define a 200 response
$.paths[*][*].responses
warn
zestful-tags-defined
All operations must have tags
$.paths[*][*].tags
warn
zestful-security-defined
Operations should define security requirements
$.paths[*][*].security
warn
zestful-info-contact
API info must include contact details
$.info

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  zestful-operation-id-camel-case:
    description: Operation IDs must use camelCase (Zestful convention)
    message: "Operation ID '{{value}}' must be camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  zestful-request-body-required:
    description: POST endpoints must define a required request body
    message: POST operation must have a required requestBody
    severity: error
    given: "$.paths[*].post"
    then:
      - field: requestBody
        function: defined
      - field: requestBody.required
        function: truthy

  zestful-ingredients-array-limits:
    description: Ingredients array must enforce min/maxItems limits
    message: Ingredients array must define minItems and maxItems
    severity: warn
    given: "$.paths[*].post.requestBody.content.application/json.schema.properties.ingredients"
    then:
      - field: minItems
        function: defined
      - field: maxItems
        function: defined

  zestful-response-200-defined:
    description: All operations must define a 200 response
    message: Operation must define a 200 success response
    severity: error
    given: "$.paths[*][*].responses"
    then:
      field: "200"
      function: defined

  zestful-tags-defined:
    description: All operations must have tags
    message: Operation must have at least one tag
    severity: warn
    given: "$.paths[*][*].tags"
    then:
      function: length
      functionOptions:
        min: 1

  zestful-security-defined:
    description: Operations should define security requirements
    message: Operation should define security requirements
    severity: warn
    given: "$.paths[*][*].security"
    then:
      function: defined

  zestful-info-contact:
    description: API info must include contact details
    message: API info must include a contact object
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: defined