Buf Schema Registry (BSR) v3.8.4
GripMock can load gRPC API definitions directly from Buf Schema Registry modules.
Basic usage
Start GripMock from a public BSR module:
gripmock --stub ./stubs buf.build/connectrpc/elizaThis uses main by default if no ref is provided.
Pin module ref
You can pin by label or commit ID:
gripmock --stub ./stubs buf.build/connectrpc/eliza:main
gripmock --stub ./stubs buf.build/connectrpc/eliza@233fca715f49425581ec0a1b660be886Custom options
Modules that use custom options, such as protovalidatebuf.validate rules, load like any other module. GripMock reads the option definitions from the module's own dependencies, so you don't need any extra configuration.
Private modules
Use default BSR profile env vars:
BSR_BUF_TOKEN=<token> gripmock --stub ./stubs buf.build/acme/private-apiConfiguration
BSR access is configured through two profiles — public Buf and self-hosted:
BSR_BUF_BASE_URL- Base URL for public BSR (default:https://buf.build)BSR_BUF_TOKEN- Token for public BSR accessBSR_BUF_TIMEOUT- Request timeout (default:5s)BSR_SELF_BASE_URL- Base URL for self-hosted BSRBSR_SELF_TOKEN- Token for self-hosted BSRBSR_SELF_TIMEOUT- Request timeout (default:5s)
Host matching
A module reference carries its host. If that host matches the one in BSR_SELF_BASE_URL, the Self profile serves it; otherwise the Buf profile does.
Examples
# 1. Public buf.build (default)
BSR_BUF_BASE_URL=https://buf.build
BSR_BUF_TOKEN=<token>
# Modules: buf.build/owner/repo → uses Buf profile
# 2. Self-hosted BSR
BSR_SELF_BASE_URL=https://bsr.company.local
BSR_SELF_TOKEN=<token>
# Host extracted from BaseURL: bsr.company.local → modules with this host use Self profileOn-premise BSR
For self-hosted BSR installations:
# Self-hosted BSR
BSR_SELF_BASE_URL=https://bsr.company.local \
BSR_SELF_TOKEN=<token> \
gripmock --stub ./stubs bsr.company.local/team/paymentsWith explicit ref:
BSR_SELF_BASE_URL=https://bsr.company.local \
BSR_SELF_TOKEN=<token> \
gripmock --stub ./stubs bsr.company.local/team/payments:mainMixed setup (public + on-prem):
# Public BSR
BSR_BUF_BASE_URL=https://buf.build
BSR_BUF_TOKEN=<public-token>
# On-premise BSR
BSR_SELF_BASE_URL=https://bsr.company.local
BSR_SELF_TOKEN=<on-prem-token>
# Routes:
# - buf.build/owner/repo → uses Buf profile
# - bsr.company.local/owner/repo → uses Self profileHow routing works
- When module is requested (e.g.,
bsr.company.local/owner/repo) - GripMock extracts the host part (
bsr.company.local) - If Self profile is configured and host matches → use Self client
- Otherwise → use Buf client
Project fixture example
This repository includes a real BSR fixture project:
cd third_party/bsr/eliza
make up
make test
make down