Buf Schema Registry (BSR)
GripMock can load gRPC API definitions directly from Buf Schema Registry modules.
Basic usage
Start GripMock from a public BSR module:
bash
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:
bash
gripmock --stub ./stubs buf.build/connectrpc/eliza:main
gripmock --stub ./stubs buf.build/connectrpc/eliza@233fca715f49425581ec0a1b660be886Private modules
Use default BSR profile env vars:
bash
BSR_BUF_TOKEN=<token> gripmock --stub ./stubs buf.build/acme/private-apiConfiguration
GripMock uses simple BSR profile configuration with these environment variables:
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
GripMock routes modules based on host matching:
GripMock uses host from BSR_SELF_BASE_URL for routing.
Examples
bash
# 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:
bash
# 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:
bash
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):
bash
# 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
This simple approach makes it easy to work with multiple BSR instances without complex configuration.
Project fixture example
This repository includes a real BSR fixture project:
bash
cd third_party/bsr/eliza
make up
make test
make down