2013-08-05 41 views

回答

3

這是完全可能的。我們有一些關於猴子補丁的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." 
      } 
+0

有沒有比這更優雅的解決方案? –

相關問題