Giter VIP home page Giter VIP logo

protoc-gen-openapi's Introduction

protoc-gen-openapi

This package copy from istio.io/tools/openapi/protoc-gen-openapi@593a41c76c5c.

What's this for?

protoc-gen-openapi is a plugin for the Google protocol buffer compiler to generate openAPI V3 spec for any given input protobuf. It runs as a protoc-gen- binary that the protobuf compiler infers from the openapi_out flag.

Build protoc-gen-openapi

protoc-gen-openapi is written in Go, so ensure that is installed on your system. You can follow the instructions on the golang website or on Debian or Ubuntu, you can install it from the package manager:

sudo apt-get install -y golang

To build, first ensure you have the protocol compiler (protoc):

go get github.com/golang/protobuf/proto

To build, run the following command from this project directory:

go build

Then ensure the resulting protoc-gen-openapi binary is in your PATH. A recommended location is $HOME/bin:

cp protoc-gen-openapi $HOME/bin

Since the following is often in your $HOME/.bashrc file:

export PATH=$HOME/bin:$PATH

Using protoc-gen-openapi


TIP

The -I option in protoc is useful when you need to specify proto paths for imports.


Then to generate the OpenAPI spec of the protobuf defined by file.proto, run

protoc --openapi_out=output_directory input_directory/file.proto

With that input, the output will be written to

output_directory/file.json

Other supported options are:

  • per_file
    • when set to true, the output is per proto file instead of per package.
  • single_file
    • when set to true, the output is a single file of all the input protos specified.
  • use_ref
    • when set to true, the output uses the $ref field in OpenAPI spec to reference other schemas.
  • yaml
    • when set to true, the output is in yaml file.

protoc-gen-openapi's People

Contributors

zchee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.