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

2022-04-23 15:23:49 +08:00
 yongchiu

有没有使用过 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: "gnostic@google.com";
    }
    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: gnostic@google.com
    license:
        name: Apache License
        url: https://github.com/google/gnostic/blob/master/LICENSE
    version: Version from annotation

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

1269 次点击
所在节点    程序员
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/848763

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX