MealMe · API Governance Rules

MealMe API Rules

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

39 Rules error 7 warn 23 info 9
View Rules File View on GitHub

Rule Categories

examples get global info no openapi operation operationid parameter paths request response schema security server servers tag

Rules

warn
info-title-mealme
API title should identify MealMe.
$.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
info
info-contact-required
A contact should be provided.
$.info
warn
openapi-version-3-1
Specs should target OpenAPI 3.1.x.
$
error
servers-defined
At least one server must be defined.
$
error
servers-https
Server URLs must use HTTPS.
$.servers[*]
info
server-is-mealme
The production server should be api.mealme.ai.
$.servers[*]
warn
paths-no-trailing-slash
Paths must not end with a trailing slash.
$.paths[*]~
error
paths-no-query-string
Path keys must not contain query strings.
$.paths[*]~
warn
paths-lowercase
Path segments use lowercase letters, digits, underscores, slashes, and braces.
$.paths[*]~
warn
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
error
operation-operationId-required
Every operation must have an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationId-camelcase
operationId should be camelCase.
$.paths[*][get,post,put,patch,delete]
info
operation-summary-title-case
Summaries should start with a capital letter.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation must be tagged.
$.paths[*][get,post,put,patch,delete]
info
global-tags-defined
Specs should declare a global tags array.
$
info
tag-has-description
Each global tag should have a description.
$.tags[*]
warn
tag-title-case
Tags should use Title Case (each word capitalized).
$.tags[*]
warn
parameter-snake-case
Parameter names should be snake_case.
$.paths[*][get,post,put,patch,delete].parameters[*]
warn
parameter-has-schema
Parameters must declare a schema.
$.paths[*][get,post,put,patch,delete].parameters[*]
error
parameter-no-api-key-in-query
API keys must travel in the Authorization header, never as a query parameter.
$.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
warn
request-body-json
Request bodies should offer an application/json representation.
$.paths[*][post,put,patch].requestBody.content
warn
response-2xx-required
Every operation must define a success (2xx) response.
$.paths[*][get,post,put,patch,delete].responses
info
response-401-documented
Authenticated operations should document a 401 response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-has-description
Each response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
warn
schema-property-snake-case
Schema property names should be snake_case (underscore-prefixed identifiers like _id allowed).
$.components.schemas[*].properties[*]~
info
schema-property-typed
Each schema property should declare a type or $ref.
$.components.schemas[*].properties[*]
warn
global-security-defined
A global security requirement should be declared.
$
warn
security-scheme-api-key-header
The API key security scheme must be an apiKey carried in the header.
$.components.securitySchemes[*]
info
security-scheme-authorization-header
The API key header should be named Authorization.
$.components.securitySchemes[?(@.in=='header')]
error
get-no-request-body
GET operations must not declare a request body.
$.paths[*].get
info
examples-encouraged
Operations are encouraged to include examples for mocking.
$.paths[*][post,put,patch].requestBody.content.application/json
warn
servers-expected-domain
Server URLs should be on the mealme.ai domain.
$.servers[*].url
warn
operationid-casing
Operation IDs should be camelCase (the dominant convention in this API).
$.paths[*][get,post,put,patch,delete].operationId
warn
schema-names-casing
Component schema names should be PascalCase (the dominant convention in this API).
$.components.schemas
warn
schema-properties-casing
Schema properties should be snake_case (the dominant convention in this API).
$.components.schemas[*].properties
warn
no-empty-descriptions
Descriptions must not be empty strings.
$..description

Spectral Ruleset

Raw ↑
# mealme — 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 mealme.ai
#   - query-params-casing: snake @ 100% (n=62)
#   - operationid-casing: camel @ 100% (n=36)
#   - schema-names-casing: pascal @ 100% (n=9)
#   - schema-properties-casing: snake @ 99% (n=85)
#   - security: global (root) — NOT emitting operation-security-required
#   - operation-documents-401: 100% adherence
#   - pagination params observed: ['page']
#   - merge: kept 34 existing, added 5 measured, upgraded 0
#   - added: servers-expected-domain, operationid-casing, schema-names-casing, schema-properties-casing, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-mealme:
    description: API title should identify MealMe.
    severity: warn
    given: $.info
    then:
      field: title
      function: pattern
      functionOptions:
        match: MealMe
  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
  info-contact-required:
    description: A contact should be provided.
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy
  openapi-version-3-1:
    description: Specs should target OpenAPI 3.1.x.
    severity: warn
    given: $
    then:
      field: openapi
      function: pattern
      functionOptions:
        match: ^3\.1\.
  servers-defined:
    description: At least one server 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://
  server-is-mealme:
    description: The production server should be api.mealme.ai.
    severity: info
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: api\.mealme\.ai
  paths-no-trailing-slash:
    description: Paths must not end with a trailing slash.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: .+/$
  paths-no-query-string:
    description: Path keys must not contain query strings.
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        notMatch: \?
  paths-lowercase:
    description: Path segments use lowercase letters, digits, underscores, slashes, and braces.
    severity: warn
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-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-description-required:
    description: Every operation must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: description
      function: truthy
  operation-operationId-required:
    description: Every operation must have an operationId.
    severity: error
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: truthy
  operation-operationId-camelcase:
    description: operationId should be camelCase.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: operationId
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]+$
  operation-summary-title-case:
    description: Summaries should start with a capital letter.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: summary
      function: pattern
      functionOptions:
        match: ^[A-Z]
  operation-tags-required:
    description: Every operation must be tagged.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  global-tags-defined:
    description: Specs should declare a global tags array.
    severity: info
    given: $
    then:
      field: tags
      function: truthy
  tag-has-description:
    description: Each global tag should have a description.
    severity: info
    given: $.tags[*]
    then:
      field: description
      function: truthy
  tag-title-case:
    description: Tags should use Title Case (each word capitalized).
    severity: warn
    given: $.tags[*]
    then:
      field: name
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z]*( [A-Z][A-Za-z]*)*$
  parameter-snake-case:
    description: Parameter names should be snake_case.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: name
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  parameter-has-schema:
    description: Parameters must declare a schema.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].parameters[*]
    then:
      field: schema
      function: truthy
  parameter-no-api-key-in-query:
    description: API keys must travel in the Authorization header, never as a query parameter.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].parameters[?(@.in=='query')]
    then:
      field: name
      function: pattern
      functionOptions:
        notMatch: (?i)(api[_-]?key|authorization|token)
  request-body-json:
    description: Request bodies should offer an application/json representation.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  response-2xx-required:
    description: Every operation must define a success (2xx) response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '200'
      function: truthy
  response-401-documented:
    description: Authenticated operations should document a 401 response.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '401'
      function: truthy
  response-has-description:
    description: Each response must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  schema-property-snake-case:
    description: Schema property names should be snake_case (underscore-prefixed identifiers like _id
      allowed).
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^_?[a-z][a-z0-9_]*$
  schema-property-typed:
    description: Each schema property should declare a type or $ref.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - type
          - required:
            - $ref
  global-security-defined:
    description: A global security requirement should be declared.
    severity: warn
    given: $
    then:
      field: security
      function: truthy
  security-scheme-api-key-header:
    description: The API key security scheme must be an apiKey carried in the header.
    severity: warn
    given: $.components.securitySchemes[*]
    then:
      field: type
      function: pattern
      functionOptions:
        match: apiKey
  security-scheme-authorization-header:
    description: The API key header should be named Authorization.
    severity: info
    given: $.components.securitySchemes[?(@.in=='header')]
    then:
      field: name
      function: pattern
      functionOptions:
        match: Authorization
  get-no-request-body:
    description: GET operations must not declare a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  examples-encouraged:
    description: Operations are encouraged to include examples for mocking.
    severity: info
    given: $.paths[*][post,put,patch].requestBody.content.application/json
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - example
          - required:
            - examples
  servers-expected-domain:
    description: Server URLs should be on the mealme.ai domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: mealme\.ai
  operationid-casing:
    description: Operation IDs should be camelCase (the dominant convention in this API).
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].operationId
    then:
      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: warn
    given: $.components.schemas[*].properties
    then:
      field: '@key'
      function: casing
      functionOptions:
        type: snake
  no-empty-descriptions:
    description: Descriptions must not be empty strings.
    severity: warn
    given: $..description
    then:
      function: truthy