V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yongchiu
V2EX  ›  程序员

从 proto 协议生成 openapi.yaml 的疑问

  •  
  •   yongchiu · 2022-04-23 15:23:49 +08:00 · 1232 次点击
    这是一个创建于 705 天前的主题,其中的信息可能已经有所发展或是发生改变。

    有没有使用过 https://github.com/google/gnostic/tree/main/cmd/protoc-gen-openapi 这个库的呢?有点问题想要咨询一下。官方提供的这个例子 https://github.com/google/gnostic/blob/main/cmd/protoc-gen-openapi/examples/tests/openapiv3annotations/message.proto ,如下所示

    option (openapi.v3.document) = {
      info: {
        title: "Title from annotation";
        version: "Version from annotation";
        description: "Description from annotation";
        contact: {
          name: "Contact Name";
          url: "https://github.com/google/gnostic";
          email: "[email protected]";
        }
        license: {
          name: "Apache License";
          url: "https://github.com/google/gnostic/blob/master/LICENSE";
        }
      }
      components: {
        security_schemes: {
          additional_properties: [
            {
              name: "BasicAuth";
              value: {
                security_scheme: {
                  type: "http";
                  scheme: "basic";
                }
              }
            }
          ]
        }
      }
    };
    

    使用了 openapiv3.proto 的参数,官方提供的例子里生成的 openapi.yaml 文件是包含这些信息的,

    info:
        title: Title from annotation
        description: Description from annotation
        contact:
            name: Contact Name
            url: https://github.com/google/gnostic
            email: [email protected]
        license:
            name: Apache License
            url: https://github.com/google/gnostic/blob/master/LICENSE
        version: Version from annotation
    

    我在本地编译该 proto 文件却没有包含这个信息,有没有大佬帮忙解答一下,感谢🙏

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5255 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 09:36 · PVG 17:36 · LAX 02:36 · JFK 05:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.