This repository demonstrates how to use Fern to generate API documentation from Protocol Buffer (.proto) files for gRPC services.
Fern can parse your .proto files and generate beautiful, interactive API reference documentation. This demo includes a sample Plant Store API with two gRPC services:
- PlantService: Manage plant listings (create, read, update, delete, search)
- OrderService: Handle customer orders
fern/
├── fern.config.json # Fern configuration with organization name
├── generators.yml # API spec configuration pointing to proto files
├── docs.yml # Documentation site configuration
└── proto/
└── plantstore/
└── v1/
├── plant_service.proto # Plant management service
└── order_service.proto # Order management service
npm install -g fern-apiTo preview your documentation locally:
fern docs devTo generate and publish your documentation:
fern generate --docsTo use this template for your own gRPC documentation:
Edit fern/fern.config.json and replace the organization name:
{
"organization": "your-organization-name",
"version": "3.32.0"
}Edit fern/docs.yml and update the URL to your desired documentation domain:
instances:
- url: https://your-org.docs.buildwithfern.comYou can also customize the title, colors, and navigation in this file.
Replace the sample proto files in fern/proto/ with your own:
- Delete the existing
fern/proto/plantstore/directory - Add your proto files following your package structure
- Update
fern/generators.ymlto point to your proto files:
api:
specs:
- proto:
root: proto
target: proto/your-package/v1/your_service.protoThe generators.yml file supports several options for proto files:
api:
specs:
- proto:
# Path to the proto directory root (where package paths start)
root: proto
# Optional: specific proto file to generate docs for
# Omit to generate docs for all proto files in root
target: proto/your-package/v1/service.protoEdit fern/docs.yml to customize your documentation:
instances:
- url: https://your-org.docs.buildwithfern.com
title: Your API | Documentation
navigation:
- api: API Reference
paginated: true
colors:
accentPrimary: '#your-brand-color'
background: '#000000'
logo:
dark: ./path/to/logo-dark.png
light: ./path/to/logo-light.pngFor the best documentation output, follow these practices in your proto files:
Comments above services, RPCs, messages, and fields become documentation:
// UserService manages user accounts
service UserService {
// Create a new user account
rpc CreateUser(CreateUserRequest) returns (User);
}
message User {
// Unique identifier for the user
string id = 1;
}enum Status {
// Default unspecified status
STATUS_UNSPECIFIED = 0;
// User is active and can access the system
STATUS_ACTIVE = 1;
}Use versioned packages for better organization:
syntax = "proto3";
package yourcompany.service.v1;For questions or issues with Fern, join the Fern Community Slack.