blob: 29d59e044fa442cd2ec66cf3b2ad10cf17388566 [file] [log] [blame] [view]
# protoc-gen-triple-openapi
`protoc-gen-triple-openapi` is a protoc plugin to generate OpenAPI v3 documentation from protobuf files that use the Triple protocol.
## Getting Started
### Installation
To install `protoc-gen-triple-openapi`, you need to have Go installed and configured. Then, you can use the following command to install the plugin:
```shell
go install github.com/apache/dubbo-go/tools/protoc-gen-triple-openapi
```
## Usage
To use `protoc-gen-triple-openapi`, you need to have a `.proto` file that defines your service. For example, you can have a file named `greet.proto` with the following content:
```proto
syntax = "proto3";
package org.apache.dubbo.samples.greet;
option go_package = "github.com/apache/dubbo-go-samples/api";
// The greeting service definition.
service GreetService {
// Sends a greeting
rpc Greet(GreetRequest) returns (GreetResponse) {}
}
// The request message containing the user's name.
message GreetRequest {
string name = 1;
}
// The response message containing the greetings
message GreetResponse {
string greeting = 1;
}
```
Then, you can use the following command to generate the OpenAPI documentation:
```shell
protoc --triple-openapi_out=. greet.proto
```
This will generate a file named `greet.openapi.yaml` with the OpenAPI documentation.