Edamam · API Governance Rules

Edamam API Rules

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

39 Rules error 8 warn 16 info 15
View Rules File View on GitHub

Rule Categories

get info openapi operation parameter paths post request response schema security servers tag tags

Rules

error
info-title-required
The API must have a title.
$.info
warn
info-title-edamam-prefix
API title should start with "Edamam".
$.info.title
warn
info-description-required
The API must have a meaningful description.
$.info
info
info-description-min-length
The API description should be at least 40 characters.
$.info.description
error
info-version-required
The API must declare a version.
$.info
info
info-contact-required
The API should declare contact information.
$.info
warn
openapi-version-3-1
Edamam specs target OpenAPI 3.1.x.
$.openapi
error
servers-defined
At least one server must be defined.
$.servers
error
servers-https-only
Servers must use HTTPS.
$.servers[*].url
info
servers-edamam-host
Production server should be api.edamam.com.
$.servers[*].url
info
servers-description
Each server should have a description.
$.servers[*]
warn
paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths[*]~
warn
paths-kebab-case
Path segments should be lowercase kebab-case (allowing version tokens like v2 and {param} placeholders).
$.paths[*]~
error
paths-no-query-string
Path keys must not contain query strings.
$.paths[*]~
error
operation-operationId-required
Every operation must declare an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationId-camelcase
operationId should be camelCase (e.g. searchRecipes, analyzeIngredient).
$.paths[*][get,post,put,patch,delete].operationId
warn
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-edamam-prefix
Operation summaries should be prefixed with "Edamam".
$.paths[*][get,post,put,patch,delete].summary
info
operation-description-required
Every operation should have a description.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation must be tagged.
$.paths[*][get,post,put,patch,delete]
info
tags-global-defined
A global tags array should be defined.
$
info
tag-description-required
Each global tag should have a description.
$.tags[*]
warn
tag-title-case
Tag names should be Title Case (e.g. "Recipe Search", "Food Database").
$.tags[*].name
warn
parameter-description-required
Every parameter should have a description.
$.paths[*][*].parameters[*]
warn
parameter-schema-type
Every parameter schema must declare a type.
$.paths[*][*].parameters[*].schema
info
parameter-example-encouraged
Parameters should provide an example value.
$.paths[*][*].parameters[*]
warn
request-body-json
Request bodies should offer application/json content.
$.paths[*][post,put,patch].requestBody.content
error
response-2xx-required
Every operation must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
info
response-401-defined
Authenticated operations should document a 401 response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-description-required
Every response must have a description.
$.paths[*][*].responses[*]
info
schema-property-camelcase
Schema property names should be camelCase, matching Edamam's JSON fields (e.g. totalNutrients, healthLabels, foodId). Underscore-prefixed HATEOAS keys like _links and SCREAMING_SNAKE nutrient codes are permitted.
$.components.schemas[*].properties[*]~
info
schema-object-type
Schemas should declare a type.
$.components.schemas[*]
warn
security-global-defined
A global security requirement should be defined.
$
warn
security-schemes-defined
Security schemes must be defined under components.
$.components
info
security-scheme-description
Each security scheme should be described.
$.components.securitySchemes[*]
error
get-no-request-body
GET operations must not declare a request body.
$.paths[*].get
info
post-has-request-body
POST operations should declare a request body.
$.paths[*].post
info
operation-microcks-extension
Operations should carry an x-microcks-operation extension for mock-server compatibility.
$.paths[*][get,post,put,patch,delete]
info
response-examples-encouraged
JSON responses should provide examples.
$.paths[*][*].responses[*].content.application/json

Spectral Ruleset

Raw ↑
# Spectral ruleset for the Edamam API surface.
#
# Generated by analyzing the Edamam OpenAPI specifications in openapi/:
#   - edamam-nutrition-analysis-api-openapi.yml
#   - edamam-food-and-grocery-database-api-openapi.yml
#   - edamam-recipe-search-api-openapi.yml
#   - edamam-meal-planner-api-openapi.yml
#
# These rules codify Edamam's observed conventions: OpenAPI 3.1, HTTPS
# api.edamam.com server, kebab-case versioned paths (/api/.../v2/...),
# camelCase operationIds and schema properties, Title Case tags, operation
# summaries prefixed with "Edamam", and app_id/app_key credential auth.
rules:

  # ── INFO / METADATA ──────────────────────────────────────────────
  info-title-required:
    description: The API must have a title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-title-edamam-prefix:
    description: API title should start with "Edamam".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: '^Edamam'
  info-description-required:
    description: The API must have a meaningful description.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-description-min-length:
    description: The API description should be at least 40 characters.
    severity: info
    given: $.info.description
    then:
      function: length
      functionOptions:
        min: 40
  info-version-required:
    description: The API must declare a version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    description: The API should declare contact information.
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy

  # ── OPENAPI VERSION ──────────────────────────────────────────────
  openapi-version-3-1:
    description: Edamam specs target OpenAPI 3.1.x.
    severity: warn
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: '^3\.1\.'

  # ── SERVERS ──────────────────────────────────────────────────────
  servers-defined:
    description: At least one server must be defined.
    severity: error
    given: $.servers
    then:
      function: length
      functionOptions:
        min: 1
  servers-https-only:
    description: Servers must use HTTPS.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: '^https://'
  servers-edamam-host:
    description: Production server should be api.edamam.com.
    severity: info
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: 'api\.edamam\.com'
  servers-description:
    description: Each server should have a description.
    severity: info
    given: $.servers[*]
    then:
      field: description
      function: truthy

  # ── PATHS — NAMING CONVENTIONS ───────────────────────────────────
  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: '.+/$'
  paths-kebab-case:
    description: Path segments should be lowercase kebab-case (allowing version tokens like v2 and {param} placeholders).
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: '^(/(\{[a-zA-Z0-9_]+\}|[a-z0-9]+(-[a-z0-9]+)*))+$'
  paths-no-query-string:
    description: Path keys must not contain query strings.
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: '\?'

  # ── OPERATIONS ───────────────────────────────────────────────────
  operation-operationId-required:
    description: Every operation must declare an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-operationId-camelcase:
    description: operationId should be camelCase (e.g. searchRecipes, analyzeIngredient).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][a-zA-Z0-9]*$'
  operation-summary-required:
    description: Every operation must have a summary.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: truthy
  operation-summary-edamam-prefix:
    description: Operation summaries should be prefixed with "Edamam".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^Edamam '
  operation-description-required:
    description: Every operation should have a description.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-tags-required:
    description: Every operation must be tagged.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy

  # ── TAGS ─────────────────────────────────────────────────────────
  tags-global-defined:
    description: A global tags array should be defined.
    severity: info
    given: $
    then:
      field: tags
      function: truthy
  tag-description-required:
    description: Each global tag should have a description.
    severity: info
    given: $.tags[*]
    then:
      field: description
      function: truthy
  tag-title-case:
    description: Tag names should be Title Case (e.g. "Recipe Search", "Food Database").
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: '^[A-Z][A-Za-z0-9]*( [A-Z][A-Za-z0-9]*)*$'

  # ── PARAMETERS ───────────────────────────────────────────────────
  parameter-description-required:
    description: Every parameter should have a description.
    severity: warn
    given: $.paths[*][*].parameters[*]
    then:
      field: description
      function: truthy
  parameter-schema-type:
    description: Every parameter schema must declare a type.
    severity: warn
    given: $.paths[*][*].parameters[*].schema
    then:
      field: type
      function: truthy
  parameter-example-encouraged:
    description: Parameters should provide an example value.
    severity: info
    given: $.paths[*][*].parameters[*]
    then:
      field: example
      function: truthy

  # ── REQUEST BODIES ───────────────────────────────────────────────
  request-body-json:
    description: Request bodies should offer application/json content.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy

  # ── RESPONSES ────────────────────────────────────────────────────
  response-2xx-required:
    description: Every operation must define at least one 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '200'
      function: truthy
  response-401-defined:
    description: Authenticated operations should document a 401 response.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  response-description-required:
    description: Every response must have a description.
    severity: warn
    given: $.paths[*][*].responses[*]
    then:
      field: description
      function: truthy

  # ── SCHEMAS — PROPERTY NAMING ────────────────────────────────────
  schema-property-camelcase:
    description: >-
      Schema property names should be camelCase, matching Edamam's JSON fields
      (e.g. totalNutrients, healthLabels, foodId). Underscore-prefixed HATEOAS
      keys like _links and SCREAMING_SNAKE nutrient codes are permitted.
    severity: info
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: '^(_?[a-z][a-zA-Z0-9]*|[A-Z][A-Z0-9_.]*)$'
  schema-object-type:
    description: Schemas should declare a type.
    severity: info
    given: $.components.schemas[*]
    then:
      field: type
      function: truthy

  # ── SECURITY ─────────────────────────────────────────────────────
  security-global-defined:
    description: A global security requirement should be defined.
    severity: warn
    given: $
    then:
      field: security
      function: truthy
  security-schemes-defined:
    description: Security schemes must be defined under components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-scheme-description:
    description: Each security scheme should be described.
    severity: info
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy

  # ── HTTP METHOD CONVENTIONS ──────────────────────────────────────
  get-no-request-body:
    description: GET operations must not declare a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  post-has-request-body:
    description: POST operations should declare a request body.
    severity: info
    given: $.paths[*].post
    then:
      field: requestBody
      function: truthy

  # ── GENERAL QUALITY ──────────────────────────────────────────────
  operation-microcks-extension:
    description: Operations should carry an x-microcks-operation extension for mock-server compatibility.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  response-examples-encouraged:
    description: JSON responses should provide examples.
    severity: info
    given: $.paths[*][*].responses[*].content.application/json
    then:
      field: examples
      function: truthy