【问题标题】:Is it possible to add a description to the Cloud Endpoint fields in the API Explorer?是否可以在 API Explorer 中向 Cloud Endpoint 字段添加描述?
【发布时间】:2013-08-05 14:38:39
【问题描述】:

我在 Google API 中看到了这一点。 Cloud Endpoints 也可以吗?

https://developers.google.com/apis-explorer/#p/adexchangebuyer/v1.2/adexchangebuyer.accounts.get

【问题讨论】:

    标签: google-app-engine google-cloud-endpoints


    【解决方案1】:

    完全有可能。我们有一些关于猴子补丁的 StackOverflow 帖子,这将是另一个很好的例子。

    例如:
    How do I specify my own icons so they show up in a Google Endpoints API discovery document?

    对于这种情况,/_ah/spi/BackendService.getApiConfigs 提供的内容包含您的 API 配置,而您在此处需要的“描述”是“参数”。

    例如在方法中

    @endpoints.method(MySchema, MySchema,
                      path='myschema/{strField}', name='myschema.echo')
    def MySchemaEcho(self, request):
      return request
    

    strField 字段是一个路径“参数”,因此在 API 配置中我们会看到

    {
      ...
      "methods": {
        "myapi.myschema.echo": {
          ...
          "request": {
            ...
            "parameters": {
              "strField": {
                "required": true,
                "type": "string"
              }
            }
          },
          ...
        }
        ...
      }
    }
    

    要在其中获取您的描述,您需要将其添加到strField 下列出的字典中,以便读取

              "strField": {
                "required": true,
                "type": "string",
                "description": "Most important field that ever was."
              }
    

    【讨论】:

    • 还有比这更优雅的解决方案吗?
    猜你喜欢
    • 2017-04-20
    • 2011-10-30
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多