tree: 9d071a4a086ab89abe1088517f5226dfe943b71b [path history] [tgz]
  1. constant/
  2. example/
  3. internal/
  4. .gitignore
  5. go.mod
  6. go.sum
  7. main.go
  8. Makefile
  9. README.md
  10. version.go
tools/protoc-gen-triple-openapi/README.md

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:

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:

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:

protoc --triple-openapi_out=. greet.proto

This will generate a file named greet.openapi.yaml with the OpenAPI documentation.