Bazel · API Governance Rules

Bazel API Rules

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

6 Rules error 1 warn 5
View Rules File View on GitHub

Rule Categories

bcr module operation tags

Rules

warn
operation-summary-title-case
Operation summaries should use Title Case.
$.paths.*[get,put,post,delete,options,head,patch,trace].summary
warn
operation-operationid-camelcase
operationId should use lowerCamelCase.
$.paths.*[get,put,post,delete,options,head,patch,trace].operationId
warn
bcr-server-required
BCR-style index registries must declare https://bcr.bazel.build or a compatible registry root as a server.
$.servers[*].url
error
bcr-modules-path-shape
Module-scoped paths must follow /modules/{module}/... shape per the Bazel index-registry protocol.
$.paths
warn
module-name-pattern
Module name parameter must be lowercase snake_case to match Bzlmod module naming.
$.components.parameters.Module.schema.pattern
warn
tags-title-case
Tags must use Title Case.
$.tags[*].name

Spectral Ruleset

Raw ↑
extends: spectral:oas
functionsDir: ./functions
rules:
  operation-summary-title-case:
    description: Operation summaries should use Title Case.
    severity: warn
    given: $.paths.*[get,put,post,delete,options,head,patch,trace].summary
    then:
      function: pattern
      functionOptions:
        match: '^([A-Z][A-Za-z0-9]*)(\s[A-Z][A-Za-z0-9]*)*$'
  operation-operationid-camelcase:
    description: operationId should use lowerCamelCase.
    severity: warn
    given: $.paths.*[get,put,post,delete,options,head,patch,trace].operationId
    then:
      function: pattern
      functionOptions:
        match: '^[a-z][A-Za-z0-9]+$'
  bcr-server-required:
    description: BCR-style index registries must declare https://bcr.bazel.build or
      a compatible registry root as a server.
    severity: warn
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: '^https://'
  bcr-modules-path-shape:
    description: Module-scoped paths must follow /modules/{module}/... shape per the
      Bazel index-registry protocol.
    severity: error
    given: $.paths
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            '^(/bazel_registry\.json|/modules/\{module\}(/(metadata\.json|\{version\}(/(MODULE\.bazel|source\.json|presubmit\.yml))?))?)$': {}
          additionalProperties:
            type: object
  module-name-pattern:
    description: Module name parameter must be lowercase snake_case to match Bzlmod
      module naming.
    severity: warn
    given: $.components.parameters.Module.schema.pattern
    then:
      function: truthy
  tags-title-case:
    description: Tags must use Title Case.
    severity: warn
    given: $.tags[*].name
    then:
      function: pattern
      functionOptions:
        match: '^([A-Z][A-Za-z0-9]*)(\s[A-Z][A-Za-z0-9]*)*$'