Lavu · API Governance Rules

Lavu API Rules

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

35 Rules error 4 warn 22 info 9
View Rules File View on GitHub

Rule Categories

info no openapi operation request response schema security servers tag tags

Rules

error
info-title-required
The API must declare a title.
$.info
warn
info-title-lavu-prefix
The API title should reference Lavu.
$.info.title
warn
info-description-required
The API must have a meaningful description (min 40 chars).
$.info
error
info-version-required
The API must declare a version.
$.info
warn
info-contact-required
The API should declare a contact.
$.info
warn
openapi-version-3
Specs must use OpenAPI 3.0.x.
$.openapi
error
servers-defined
At least one server must be defined.
$
warn
servers-https
Server URLs must use HTTPS (POSLavu request servers are HTTPS).
$.servers[*].url
info
servers-description
Each server should be described.
$.servers[*]
error
operation-operationid-required
Every operation must declare an operationId.
$.paths[*][get,post,put,patch,delete]
warn
operation-operationid-camel-case
operationId must be camelCase (e.g. queryTable, insertRecords).
$.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-lavu-prefix
Operation summaries must begin with the provider name "Lavu".
$.paths[*][get,post,put,patch,delete].summary
warn
operation-description-required
Every operation must have a description.
$.paths[*][get,post,put,patch,delete]
warn
operation-tags-required
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
info
operation-microcks-extension
Each operation should carry an x-microcks-operation extension for mocking.
$.paths[*][get,post,put,patch,delete]
info
tags-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 must be Title Case (e.g. Menu, Orders, Inventory).
$.tags[*].name
warn
request-body-form-encoded
POSLavu accepts form-encoded request bodies; operations should expose an application/x-www-form-urlencoded media type.
$.paths[*][post,put,patch].requestBody.content
warn
request-body-schema
Request body media types must declare a schema.
$.paths[*][post,put,patch].requestBody.content[*]
warn
response-2xx-required
Every operation must define a 2xx success response.
$.paths[*][get,post,put,patch,delete].responses
warn
response-description-required
Every response must have a description.
$.paths[*][get,post,put,patch,delete].responses[*]
info
response-xml-content
POSLavu returns XML; responses should expose an application/xml media type.
$.paths[*][get,post,put,patch,delete].responses[*].content
warn
schema-property-snake-case
Schema property names must be snake_case to match POSLavu table columns (acronym columns such as UPC are exempt).
$.components.schemas[*].properties.*~
warn
schema-property-type
Every schema property must declare a type or a $ref.
$.components.schemas[*].properties[*]
info
schema-property-description
Schema properties should carry a description.
$.components.schemas[*].properties[*]
info
schema-table-enum
The table selector should be constrained to the documented POSLavu tables via an enum.
$.components.schemas.QueryRequest.properties.table
warn
security-scheme-defined
At least one security scheme must be defined.
$.components.securitySchemes
info
security-scheme-described
Each security scheme should be described.
$.components.securitySchemes[*]
info
operation-security-required
Every operation should declare its security requirements (dataname/key/token).
$.paths[*][get,post,put,patch,delete]
warn
servers-expected-domain
Server URLs should be on the poslavu.com domain.
$.servers[*].url
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 ↑
# lavu — 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: 2/2 servers on poslavu.com
#   - schema-names-casing: pascal @ 100% (n=11)
#   - schema-properties-casing: snake @ 100% (n=224)
#   - operation-security-required: 2/2 ops declare per-op security
#   - merge: kept 31 existing, added 4 measured, upgraded 0
#   - added: servers-expected-domain, schema-names-casing, schema-properties-casing, no-empty-descriptions
extends:
  - spectral:oas
rules:
  info-title-required:
    description: The API must declare a title.
    severity: error
    given: $.info
    then:
      field: title
      function: truthy
  info-title-lavu-prefix:
    description: The API title should reference Lavu.
    severity: warn
    given: $.info.title
    then:
      function: pattern
      functionOptions:
        match: Lavu
  info-description-required:
    description: The API must have a meaningful description (min 40 chars).
    severity: warn
    given: $.info
    then:
      field: description
      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 a contact.
    severity: warn
    given: $.info
    then:
      field: contact
      function: truthy
  openapi-version-3:
    description: Specs must use OpenAPI 3.0.x.
    severity: warn
    given: $.openapi
    then:
      function: pattern
      functionOptions:
        match: ^3\.0\.\d+$
  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 (POSLavu request servers are HTTPS).
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: ^https://
  servers-description:
    description: Each server should be described.
    severity: info
    given: $.servers[*]
    then:
      field: description
      function: truthy
  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-camel-case:
    description: operationId must be camelCase (e.g. queryTable, insertRecords).
    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-lavu-prefix:
    description: Operation summaries must begin with the provider name "Lavu".
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: '^Lavu '
  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-tags-required:
    description: Every operation must declare at least one tag.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: tags
      function: truthy
  operation-microcks-extension:
    description: Each operation should carry an x-microcks-operation extension for mocking.
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: x-microcks-operation
      function: truthy
  tags-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 must be Title Case (e.g. Menu, Orders, Inventory).
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: ^[A-Z][A-Za-z]+( [A-Z][A-Za-z]+)*$
  request-body-form-encoded:
    description: POSLavu accepts form-encoded request bodies; operations should expose an application/x-www-form-urlencoded
      media type.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content
    then:
      field: application/x-www-form-urlencoded
      function: truthy
  request-body-schema:
    description: Request body media types must declare a schema.
    severity: warn
    given: $.paths[*][post,put,patch].requestBody.content[*]
    then:
      field: schema
      function: truthy
  response-2xx-required:
    description: Every operation must define a 2xx success response.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses
    then:
      field: '200'
      function: truthy
  response-description-required:
    description: Every response must have a description.
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].responses[*]
    then:
      field: description
      function: truthy
  response-xml-content:
    description: POSLavu returns XML; responses should expose an application/xml media type.
    severity: info
    given: $.paths[*][get,post,put,patch,delete].responses[*].content
    then:
      field: application/xml
      function: truthy
  schema-property-snake-case:
    description: Schema property names must be snake_case to match POSLavu table columns (acronym columns
      such as UPC are exempt).
    severity: warn
    given: $.components.schemas[*].properties.*~
    then:
      function: pattern
      functionOptions:
        match: ^[a-z][a-z0-9_]*$|^[A-Z]+$
  schema-property-type:
    description: Every schema property must declare a type or a $ref.
    severity: warn
    given: $.components.schemas[*].properties[*]
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
          - required:
            - type
          - required:
            - $ref
  schema-property-description:
    description: Schema properties should carry a description.
    severity: info
    given: $.components.schemas[*].properties[*]
    then:
      field: description
      function: truthy
  schema-table-enum:
    description: The table selector should be constrained to the documented POSLavu tables via an enum.
    severity: info
    given: $.components.schemas.QueryRequest.properties.table
    then:
      field: enum
      function: truthy
  security-scheme-defined:
    description: At least one security scheme must be defined.
    severity: warn
    given: $.components.securitySchemes
    then:
      function: truthy
  security-scheme-described:
    description: Each security scheme should be described.
    severity: info
    given: $.components.securitySchemes[*]
    then:
      field: description
      function: truthy
  operation-security-required:
    description: Every operation should declare its security requirements (dataname/key/token).
    severity: info
    given: $.paths[*][get,post,put,patch,delete]
    then:
      field: security
      function: truthy
  servers-expected-domain:
    description: Server URLs should be on the poslavu.com domain.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: poslavu\.com
  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