Giter Site home page Giter Site logo

albenik / twirp-openapi-gen Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 14 KB

A Twirp RPC OpenAPI generator implemented as `protoc` plugin

License: Apache License 2.0

Go 100.00%
protobuf protoc openapi swagger twirp golang protoc-plugin protoc-gen

twirp-openapi-gen's Introduction

twirp-openapi-gen

A Twirp RPC OpenAPI generator implemented as protoc plugin

Currently supports only OpenAPI 2.0

Usage

Installing the generator for protoc/buf:

go install github.com/albenik/twirp-openapi-gen/cmd/protoc-gen-twirp-openapi@latest

Run whith the protoc

protoc -twirp-openapi_out=api/foo -twirp-openapi_opt=hostname=api.example.com,path_prefix=/api/v1 rpc/service.proto

Run with buf.build:

buf.gen.yaml:

version: v1
plugins:
  - name: twirp-openapi
    out: api/foo
    opt:
     - hostname=api.example.com
     - path_prefix=/api/v1

Motivation

The only working generator referenced by Twirp project and found by me is go-bridget/protoc-gen-twirp_swagger. It lacks support of map (at least) and also does not work with advanced buf configuration when buf.work.yaml and buf.gen.yaml placed on the different levels.

I started from a PR to the original go-bridget/twirp-swagger-gen but later decided to write generator from scratch. I dropped stadalone proto parser package and just rely on already parsed structure from protogen. Also I don't use OpenAPI spec go-package and replaced it by hand-written structures, which are incomplete buf much more comfortable to use.

The generated output is suitable for Swagger-UI.

twirp-openapi-gen's People

Contributors

albenik avatar darkliquid avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

darkliquid

twirp-openapi-gen's Issues

not support optional tag

core/proto/base/base.proto: is a proto3 file that contains optional fields, but code generator protoc-gen-twirp-openapi hasn't been updated to support optional fields in proto3. Please ask the owner of this code generator to support proto3 optional.--twirp-openapi_out:

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.