Skip to content

Commit

Permalink
Add sample files for Buf plugin tutorial (#33)
Browse files Browse the repository at this point in the history
Docs updates PR: bufbuild/buf.build#1865
  • Loading branch information
rakuista authored Sep 18, 2024
1 parent 27cd5e8 commit 980a4bf
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ This repository contains all of the example code for the Buf tours and tutorials
- **[Code linting tutorial][lint]** – Demonstrates how the Buf CLI code linter can help ensure forward compatibility
in your Protobuf files.

- **[Buf plugin tutorial][plugin]** – Walks you through creating a custom lint rule using the [Bufplugin framework][bufplugin].

[breaking]: https://buf.build/docs/breaking/tutorial
[bsr]: https://buf.build/docs/tutorials/getting-started-with-bsr
[buf-cli]: https://buf.build/docs/tutorials/getting-started-with-buf-cli
[bufplugin]: https://github.com/bufbuild/bufplugin/tree/main
[lint]: https://buf.build/docs/lint/tutorial
[plugin]: https://buf.build/docs/breaking/tutorial
[bsr]: https://buf.build/docs/cli/buf-plugins/tutorial-create-buf-plugin
17 changes: 17 additions & 0 deletions finish/tutorial-create-buf-plugin/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v2
modules:
- path: proto
name: buf.build/tutorials/create-buf-plugin
lint:
use:
- DEFAULT
- RPC_SUFFIX
breaking:
use:
- FILE
plugins:
- plugin: rpc-suffix
options:
forbidden_rpc_suffixes:
- Method
- RPC
32 changes: 32 additions & 0 deletions finish/tutorial-create-buf-plugin/proto/pet/v1/pet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

package pet.v1;

// PetType represents the different types of pets in the pet store.
enum PetType {
PET_TYPE_UNSPECIFIED = 0;
PET_TYPE_CAT = 1;
PET_TYPE_DOG = 2;
PET_TYPE_SNAKE = 3;
PET_TYPE_HAMSTER = 4;
}

// Pet represents a pet in the pet store.
message Pet {
PetType pet_type = 1;
string pet_id = 2;
string name = 3;
}

message GetPetRequest {
string pet_id = 1;
}

message GetPetResponse {
Pet pet = 1;
}

service PetStoreService {
rpc GetPet(GetPetRequest) returns (GetPetResponse) {}

}
10 changes: 10 additions & 0 deletions start/tutorial-create-buf-plugin/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v2
modules:
- path: proto
name: buf.build/tutorials/create-buf-plugin
lint:
use:
- DEFAULT
breaking:
use:
- FILE
32 changes: 32 additions & 0 deletions start/tutorial-create-buf-plugin/proto/pet/v1/pet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

package pet.v1;

// PetType represents the different types of pets in the pet store.
enum PetType {
PET_TYPE_UNSPECIFIED = 0;
PET_TYPE_CAT = 1;
PET_TYPE_DOG = 2;
PET_TYPE_SNAKE = 3;
PET_TYPE_HAMSTER = 4;
}

// Pet represents a pet in the pet store.
message Pet {
PetType pet_type = 1;
string pet_id = 2;
string name = 3;
}

message GetPetRequest {
string pet_id = 1;
}

message GetPetResponse {
Pet pet = 1;
}

service PetStoreService {
rpc GetPetMethod(GetPetRequest) returns (GetPetResponse) {}

}

0 comments on commit 980a4bf

Please sign in to comment.