Lunchbox · API Governance Rules

Lunchbox API Rules

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

37 Rules error 8 warn 21 info 8
View Rules File View on GitHub

Rule Categories

delete get info no openapi operation parameter path paths query request response schema security servers tag tags

Rules

warn
info-title-lunchbox
API title should start with "Lunchbox".
$.info.title
warn
info-description-required
Info description is required and should be meaningful.
$.info
error
info-version-required
Info version is required.
$.info
info
info-contact-required
Contact information should be provided.
$.info
error
openapi-version-3
Specs must use OpenAPI 3.0.x.
$.openapi
error
servers-defined
At least one server must be defined.
$.servers
warn
servers-https
Server URLs must use HTTPS.
$.servers[*].url
info
servers-description
Each server should have a description.
$.servers[*]
warn
paths-no-trailing-slash
Paths should not end with a trailing slash (except root collections).
$.paths[*]~
error
paths-no-query-string
Path keys must not contain query strings.
$.paths[*]~
warn
operation-summary-required
Every operation must have a summary.
$.paths[*][get,post,put,patch,delete]
warn
operation-summary-lunchbox-prefix
Operation summaries should start with "Lunchbox".
$.paths[*][get,post,put,patch,delete].summary
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].operationId
warn
operation-tags-required
Every operation must have at least one tag.
$.paths[*][get,post,put,patch,delete]
info
tags-global-defined
A global tags array should be defined.
$
info
tag-description
Each global tag should have a description.
$.tags[*]
warn
tag-title-case
Tag names should be Title Case (e.g., "User Wallet", "Service Types").
$.tags[*].name
warn
parameter-snake-case
Parameter names should be snake_case (Lunchbox convention).
$.paths[*][*].parameters[*].name
error
parameter-schema-required
Each parameter must define a schema.
$.paths[*][*].parameters[*]
warn
request-body-json
Request bodies should offer application/json.
$.paths[*][post,put,patch].requestBody.content
error
response-success-defined
Each operation must define at least one 2xx response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-description-required
Each response must have a description.
$.paths[*][*].responses[*]
info
schema-property-snake-case
Schema property names should be snake_case (Core/Management/POS convention).
$.components.schemas[*].properties[*]~
info
schema-property-typed
Schema properties should declare a type or a $ref.
$.components.schemas[*].properties[*]
warn
security-global-defined
A global security requirement should be defined.
$
warn
security-schemes-defined
Security schemes must be declared under components.
$.components
info
security-scheme-described
Each security scheme should have a description.
$.components.securitySchemes[*]
error
get-no-request-body
GET operations must not declare a request body.
$.paths[*].get
warn
delete-no-request-body
DELETE operations should not declare a request body.
$.paths[*].delete
info
operation-examples-encouraged
Operations are encouraged to provide response examples.
$.paths[*][*].responses[*].content.application/json
warn
servers-expected-domain
Server URLs should be on the lunchbox.io 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 snake_case (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
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 ↑
# lunchbox — 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: 3/3 servers on lunchbox.io
#   - path-params-casing: snake @ 100% (n=100)
#   - query-params-casing: snake @ 100% (n=30)
#   - operationid-casing: camel @ 100% (n=102)
#   - schema-names-casing: pascal @ 100% (n=33)
#   - schema-properties-casing: snake @ 93% (n=207)
#   - security: global (root) — NOT emitting operation-security-required
#   - pagination params observed: ['limit', 'page']
#   - merge: kept 31 existing, added 6 measured, upgraded 0
#   - added: servers-expected-domain, path-params-casing, query-params-casing, schema-names-casing, schema-properties-casing, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-lunchbox:
    description: API title should start with "Lunchbox".
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: ^Lunchbox
  info-description-required:
    description: Info description is required and should be meaningful.
    severity: warn
    given: $.info
    then:
      field: description
      function: truthy
  info-version-required:
    description: Info version is required.
    severity: error
    given: $.info
    then:
      field: version
      function: truthy
  info-contact-required:
    description: Contact information should be provided.
    severity: info
    given: $.info
    then:
      field: contact
      function: truthy
  openapi-version-3:
    description: Specs must use OpenAPI 3.0.x.
    severity: error
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.0\.\d+$
  servers-defined:
    description: At least one server must be defined.
    severity: error
    given: $.servers
    then:
      function: truthy
  servers-https:
    description: Server URLs must use HTTPS.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-description:
    description: Each server should have a description.
    severity: info
    given: $.servers[*]
    then:
      field: description
      function: truthy
  paths-no-trailing-slash:
    description: Paths should not end with a trailing slash (except root collections).
    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: \?
  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-lunchbox-prefix:
    description: Operation summaries should start with "Lunchbox".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^Lunchbox '
  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].operationId
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-zA-Z0-9]*$
  operation-tags-required:
    description: Every operation must have at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  tags-global-defined:
    description: A global tags array should be defined.
    severity: info
    given: $
    then:
      field: tags
      function: truthy
  tag-description:
    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., "User Wallet", "Service Types").
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z]*( [A-Z][A-Za-z]*)*$
  parameter-snake-case:
    description: Parameter names should be snake_case (Lunchbox convention).
    severity: warn
    given: $.paths[*][*].parameters[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$
  parameter-schema-required:
    description: Each parameter must define a schema.
    severity: error
    given: $.paths[*][*].parameters[*]
    then:
      field: schema
      function: truthy
  request-body-json:
    description: Request bodies should offer application/json.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/json
      function: truthy
  response-success-defined:
    description: Each operation must define at least one 2xx response.
    severity: error
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            ^2\d\d$: {}
          minProperties: 1
  response-description-required:
    description: Each response must have a description.
    severity: warn
    given: $.paths[*][*].responses[*]
    then:
      field: description
      function: truthy
  schema-property-snake-case:
    description: Schema property names should be snake_case (Core/Management/POS convention).
    severity: info
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: ^[a-zA-Z][a-zA-Z0-9_]*$
  schema-property-typed:
    description: Schema properties should declare a type or a $ref.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - type
          - required:
            - $ref
          - required:
            - allOf
          - required:
            - oneOf
          - required:
            - anyOf
  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 declared under components.
    severity: warn
    given: $.components
    then:
      field: securitySchemes
      function: truthy
  security-scheme-described:
    description: Each security scheme should have a description.
    severity: info
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy
  get-no-request-body:
    description: GET operations must not declare a request body.
    severity: error
    given: $.paths[*].get
    then:
      field: requestBody
      function: falsy
  delete-no-request-body:
    description: DELETE operations should not declare a request body.
    severity: warn
    given: $.paths[*].delete
    then:
      field: requestBody
      function: falsy
  operation-examples-encouraged:
    description: Operations are encouraged to provide response examples.
    severity: info
    given: $.paths[*][*].responses[*].content.application/json
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - example
          - required:
            - examples
          - required:
            - schema
  servers-expected-domain:
    description: Server URLs should be on the lunchbox.io domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: lunchbox\.io
  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 snake_case (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: snake
  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