// HTTP handlers with automatic validation (both headers and body)
api.RegisterUserServiceServer(userService, api.WithMux(mux))
// Mock server with realistic data (optional)
mockService := api.NewMockUserServiceServer()
api.RegisterUserServiceServer(mockService, api.WithMux(mux))
// Helper functions
req := api.NewCreateUserRequestEmail("user@example.com", "secret")
req := api.NewCreateUserRequestToken("auth-token")
// Validation happens automatically:
// - Headers validated first (returns HTTP 400 for missing/invalid headers)
// - Then request body validated (returns HTTP 400 for invalid requests)
// OpenAPI docs (UserService.openapi.yaml) - includes validation rules, headers, and examples
Quick setup
# Install the tools
go install github.com/SebastienMelki/sebuf/cmd/protoc-gen-go-oneof-helper@latest
go install github.com/SebastienMelki/sebuf/cmd/protoc-gen-go-http@latest
go install github.com/SebastienMelki/sebuf/cmd/protoc-gen-openapiv3@latest
# Try the complete example
cd examples/simple-api && make demo