Spoonacular · API Governance Rules

Spoonacular API Rules

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

29 Rules error 6 warn 19 info 4
View Rules File View on GitHub

Rule Categories

info no openapi operation parameter path paths query response schema security servers tag

Rules

warn
info-title-prefix
API title should reference spoonacular.
$.info
warn
info-description-required
Info object must have a non-empty description.
$.info
error
info-version-required
Info object must declare a version.
$.info
error
openapi-version-3
Spec must be OpenAPI 3.x.
$
error
servers-defined
A servers array must be defined.
$
error
servers-https
Server URLs must use HTTPS.
$.servers[*]
warn
paths-no-trailing-slash
Paths should not end with a trailing slash.
$.paths[*]~
info
paths-camel-case
Path segments use camelCase (Spoonacular convention, e.g. /recipes/complexSearch).
$.paths[*]~
warn
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,delete,patch]
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,delete,patch]
error
operation-operationid-required
Every operation must have an operationId.
$.paths[*][get,post,put,delete,patch]
warn
operation-operationid-camel-case
operationId should be camelCase (e.g. searchRecipes, getRecipeInformation).
$.paths[*][get,post,put,delete,patch].operationId
warn
operation-tags-required
Every operation must be tagged.
$.paths[*][get,post,put,delete,patch]
warn
tag-title-case
Tag names must be Title Case (e.g. Recipes, Meal Planning, Menu Items).
$.paths[*][get,post,put,delete,patch].tags[*]
info
parameter-description-required
Parameters should have a description.
$.paths[*][get,post,put,delete,patch].parameters[*]
warn
parameter-schema-typed
Parameters must define a typed schema.
$.paths[*][get,post,put,delete,patch].parameters[*].schema
warn
response-success-defined
Operations must define a 200 (or 2xx) success response.
$.paths[*][get,post,put,delete,patch].responses
warn
security-global-defined
A global security requirement must be declared.
$
error
security-apikey-header
The API key security scheme must be an apiKey delivered in the x-api-key header.
$.components.securitySchemes.apiKeyScheme
info
operation-examples-encouraged
Operations are encouraged to provide response examples for mocking.
$.paths[*][get,post,put,delete,patch].responses[*].content[*]
warn
servers-expected-domain
Server URLs should be on the spoonacular.com domain.
$.servers[*].url
warn
path-params-casing
Path parameters should be snake_case (the dominant convention in this API).
$.paths[*].parameters[?(@.in=='path')].name
warn
query-params-casing
Query parameters should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
info
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
operation-documents-401
Operations should document a 401 response (documented on 100% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses
warn
operation-documents-403
Operations should document a 403 response (documented on 100% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses
warn
operation-documents-404
Operations should document a 404 response (documented on 100% of this API's operations).
$.paths[*][get,post,put,patch,delete].responses
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# spoonacular — Spectral ruleset (strengthened)
# Plain Spectral. Existing hand-authored rules preserved; measured rules added
# from this provider's own OpenAPI conventions by strengthen_ruleset.py,
# then self-validated against the spec.
#
# Provenance:
#   - servers-https-only: 100% of servers already https (error)
#   - servers-expected-domain: 1/1 servers on spoonacular.com
#   - path-params-casing: snake @ 100% (n=57)
#   - query-params-casing: camel @ 67% (n=364)
#   - operationid-casing: camel @ 100% (n=99)
#   - schema-names-casing: pascal @ 100% (n=8)
#   - schema-properties-casing: snake @ 63% (n=108)
#   - security: global (root) — NOT emitting operation-security-required
#   - operation-documents-401: 100% adherence
#   - operation-documents-403: 100% adherence
#   - operation-documents-404: 100% adherence
#   - pagination params observed: ['offset', 'page']
#   - merge: kept 20 existing, added 9 measured, upgraded 0
#   - added: servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, operation-documents-401, operation-documents-403, operation-documents-404, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-prefix:
    description: API title should reference spoonacular.
    severity: warn
    given: $.info
    then:
      field: title
      function: pattern
      functionOptions:
        match: (?i)spoonacular
  info-description-required:
    description: Info object must have a non-empty description.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info object must declare a version.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  openapi-version-3:
    description: Spec must be OpenAPI 3.x.
    severity: error
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.
  servers-defined:
    description: A servers array must be defined.
    severity: error
    given: $
    then:
      field: servers
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS.
    severity: error
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: ^https://
  paths-no-trailing-slash:
    description: Paths should not end with a trailing slash.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: .+/$
  paths-camel-case:
    description: Path segments use camelCase (Spoonacular convention, e.g. /recipes/complexSearch).
    severity: info
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^(/[a-zA-Z0-9{}\-]+)+$
  operation-summary-required:
    description: Every operation must have a summary.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: summary
      function: truthy
  operation-description-required:
    description: Every operation must have a description.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: description
      function: truthy
  operation-operationid-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: operationId
      function: truthy
  operation-operationid-camel-case:
    description: operationId should be camelCase (e.g. searchRecipes, getRecipeInformation).
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-tags-required:
    description: Every operation must be tagged.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch]
    then:
      field: tags
      function: truthy
  tag-title-case:
    description: Tag names must be Title Case (e.g. Recipes, Meal Planning, Menu Items).
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].tags[*]
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z]*( [A-Z][A-Za-z]*)*$
  parameter-description-required:
    description: Parameters should have a description.
    severity: info
    given: $.paths[*][get,post,put,delete,patch].parameters[*]
    then:
      field: description
      function: truthy
  parameter-schema-typed:
    description: Parameters must define a typed schema.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].parameters[*].schema
    then:
      field: type
      function: truthy
  response-success-defined:
    description: Operations must define a 200 (or 2xx) success response.
    severity: warn
    given: $.paths[*][get,post,put,delete,patch].responses
    then:
      field: '200'
      function: truthy
  security-global-defined:
    description: A global security requirement must be declared.
    severity: warn
    given: $
    then:
      field: security
      function: truthy
  security-apikey-header:
    description: The API key security scheme must be an apiKey delivered in the x-api-key header.
    severity: error
    given: $.components.securitySchemes.apiKeyScheme
    then:
    - field: type
      function: pattern
      functionOptions:
        match: ^apiKey$
    - field: in
      function: pattern
      functionOptions:
        match: ^header$
    - field: name
      function: pattern
      functionOptions:
        match: ^x-api-key$
  operation-examples-encouraged:
    description: Operations are encouraged to provide response examples for mocking.
    severity: info
    given: $.paths[*][get,post,put,delete,patch].responses[*].content[*]
    then:
      function: defined
      field: examples
  servers-expected-domain:
    description: Server URLs should be on the spoonacular.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: spoonacular\.com
  path-params-casing:
    description: Path parameters should be snake_case (the dominant convention in this API).
    severity: warn
    given: $.paths[*].parameters[?(@.in=='path')].name
    then:
      function: casing
      functionOptions:
        type: snake
  query-params-casing:
    description: Query parameters should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: casing
      functionOptions:
        type: camel
  schema-names-casing:
    description: Component schema names should be PascalCase (the dominant convention in this API).
    severity: warn
    given: $.components.schemas
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: pascal
  schema-properties-casing:
    description: Schema properties should be snake_case (the dominant convention in this API).
    severity: info
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  operation-documents-401:
    description: Operations should document a 401 response (documented on 100% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  operation-documents-403:
    description: Operations should document a 403 response (documented on 100% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '403'
      function: truthy
  operation-documents-404:
    description: Operations should document a 404 response (documented on 100% of this API's operations).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '404'
      function: truthy
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy