@@ -29,17 +29,27 @@ This starts a working HTTP API with JSON endpoints and OpenAPI docs - all genera
2929
3030## What you get
3131
32- - ** HTTP handlers** from protobuf services (JSON + binary support)
33- - ** Type-safe Go HTTP clients** with functional options pattern and per-call customization
34- - ** TypeScript HTTP clients** with full type safety, header helpers, and error handling
35- - ** TypeScript HTTP servers** using the Web Fetch API, framework-agnostic (Node, Deno, Bun, Cloudflare Workers)
36- - ** Mock server generation** with realistic field examples for rapid prototyping
37- - ** Automatic request validation** using protovalidate with buf.validate annotations
38- - ** HTTP header validation** with type checking and format validation (UUID, email, datetime)
39- - ** Structured error responses** with field-level validation details in JSON or protobuf
40- - ** Automatic Go error interface** for any message ending with "Error", enabling ` errors.As() ` and ` errors.Is() `
41- - ** OpenAPI v3.1 docs** that stay in sync with your code, one file per service for better organization
42- - ** Zero runtime dependencies** - works with any Go HTTP framework
32+ ** Five generators from one ` .proto ` file:**
33+
34+ | Generator | Output |
35+ | -----------| --------|
36+ | ` protoc-gen-go-http ` | Go HTTP handlers with routing, request binding, and validation |
37+ | ` protoc-gen-go-client ` | Type-safe Go HTTP clients with functional options and per-call customization |
38+ | ` protoc-gen-ts-client ` | TypeScript HTTP clients with full type safety, header helpers, and error handling |
39+ | ` protoc-gen-ts-server ` | TypeScript HTTP servers using the Web Fetch API — works with Node, Deno, Bun, Cloudflare Workers |
40+ | ` protoc-gen-openapiv3 ` | OpenAPI v3.1 specs that stay in sync with your code, one file per service |
41+
42+ ** Validation and error handling — built in, not bolted on:**
43+
44+ - Automatic request body validation via [ buf.validate] ( https://github.com/bufbuild/protovalidate ) annotations
45+ - HTTP header validation with type checking and format validation (UUID, email, datetime)
46+ - Structured error responses with field-level details in JSON or protobuf
47+ - Proto messages ending with "Error" automatically implement Go's ` errors.As() ` / ` errors.Is() `
48+
49+ ** Developer experience:**
50+
51+ - Mock server generation with realistic field examples for rapid prototyping
52+ - Zero runtime dependencies — works with any Go HTTP framework
4353
4454## How it works
4555
@@ -84,38 +94,41 @@ message CreateUserRequest {
8494```
8595
8696sebuf generates:
97+
98+ ** Go** — handlers, clients, and mocks:
8799``` go
88- // HTTP handlers with automatic validation (both headers and body)
100+ // HTTP handlers with automatic validation (headers + body)
89101api.RegisterUserServiceServer (userService, api.WithMux (mux))
90102
91- // Type-safe Go HTTP client with functional options
103+ // Type-safe HTTP client with functional options
92104client := api.NewUserServiceClient (" http://localhost:8080" ,
93105 api.WithUserServiceAPIKey (" your-api-key" ),
94106)
95107user , err := client.CreateUser (ctx, req)
96108
97- // Mock server with realistic data (optional)
109+ // Mock server with realistic data
98110mockService := api.NewMockUserServiceServer ()
99111api.RegisterUserServiceServer (mockService, api.WithMux (mux))
100-
101- // Validation happens automatically:
102- // - Headers validated first (returns HTTP 400 for missing/invalid headers)
103- // - Then request body validated (returns HTTP 400 for invalid requests)
104- // OpenAPI docs (UserService.openapi.yaml) - includes validation rules, headers, and examples
105112```
106113
114+ ** TypeScript** — clients and servers:
107115``` typescript
108- // TypeScript HTTP client with full type safety
116+ // HTTP client with full type safety
109117const client = new UserServiceClient (" http://localhost:8080" , {
110118 apiKey: " your-api-key" ,
111119});
112120const user = await client .createUser ({ name: " John" , email: " john@example.com" });
113121
114- // TypeScript HTTP server (framework-agnostic, Web Fetch API)
122+ // HTTP server (framework-agnostic, Web Fetch API)
115123const routes = createUserServiceRoutes (handler );
116124// Wire into any framework: Bun.serve, Deno.serve, Express, Hono, etc.
117125```
118126
127+ ** OpenAPI** — validation rules, headers, and examples included automatically:
128+ ```
129+ UserService.openapi.yaml
130+ ```
131+
119132## Quick setup
120133
121134``` bash
@@ -169,14 +182,6 @@ sebuf is used at [Sarwa](https://www.sarwa.co/), the fastest-growing investment
169182- ** [ Documentation] ( ./docs/ ) ** - Comprehensive guides and API reference
170183- ** [ More Examples] ( ./docs/examples/ ) ** - Additional patterns and use cases
171184
172- ## What's this good for?
173-
174- - ** Web & mobile APIs** - JSON/HTTP endpoints from protobuf definitions
175- - ** API documentation** - OpenAPI specs that never get out of sync
176- - ** Type-safe development** - Leverage protobuf's type system for HTTP APIs
177- - ** Client generation** - Generate Go and TypeScript clients directly from your protobuf definitions
178- - ** Server generation** - Generate TypeScript HTTP servers using the Web Fetch API
179-
180185## Built on Great Tools
181186
182187sebuf stands on the shoulders of giants, integrating with an incredible ecosystem:
0 commit comments