简体   繁体   中英

How do you convert an OpenAPI Spec (Swagger 2.0) to proto3?

I've done extensive Google searching but couldn't find a good tool to do this. The closest I could find was https://github.com/googleapis/gnostic , which allows converting an OpenAPI description (swagger.yaml) into a .pb file or a .json file. I'm wondering if there are any tools to convert this .pb file into a .proto proto3 file?

I also tried https://github.com/NYTimes/openapi2proto but unfortunately there are a few cases that aren't handled correctly.

Thanks in advance for your help!

I know this question is old, but I was wandering the same and it seems that things have changed in meantime. So I will post an answer for others, lazy enough to search :)

Currently there are several options to convert OpenApi 2/3 to Protobuf:

  • OpenAPITools/openapi-generator supports this from version 4.1.2, find more here .
  • googleapis/gnostic can do this as well, find more here .
  • nytimes/openapi2proto a tool written in go for this, find more here .
  • maybe some more...? add if i missed any.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM