当ResourceContainer定义为两个或更多时,endpointscfg.py不起作用

时间:2017-10-24 15:10:49

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

我定义了两个ResourceContainer。

但echov1openapi.json是由endpointscfg.py生成的,只有一个Container。

如:

class TestRequest(messages.Message):
    foo = messages.StringField(1)
    bar = messages.StringField(2)

class EchoRequest(messages.Message):
    aaa = messages.StringField(1)
    bbb = messages.StringField(2)

ECHO_RESOURCE = endpoints.ResourceContainer(
    EchoRequest,
    n=messages.IntegerField(3))

TEST_RESOURCE   = endpoints.ResourceContainer(
    TestRequest,
    test=messages.IntegerField(3))
...
    @endpoints.method(
        ECHO_RESOURCE,
        EchoResponse,
        path='echo',
        http_method='POST',
        name='echoTest')
    def echo(self, request):
        ...    
    @endpoints.method(
        TEST_RESOURCE,
        EchoResponse,
        path='echo2',
        http_method='POST',
        name='echo2')
    def echo2(self, request):
        ....

然后,我执行endpointscfg.py。但是没有出现TEST_RESOURCE。

  "definitions": {
...
    "ProtorpcMessagesCombinedContainer": { ★ECHO_RESOURCE
      "properties": {
        "aaa": {
          "type": "string"
        },
        "bbb": {
          "type": "string"
        },
        "n": {
          "format": "int64",
          "type": "string"
        }
      },
      "type": "object"
    }
  },
...
  "paths": {
    "/echo/v1/echo": {
      "post": {
        "operationId": "EchoApi_echo",
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "schema": {
              "$ref": "#/definitions/ProtorpcMessagesCombinedContainer"★refer ECHO_RESOURCE
            }
          }
        ],
...
    "/echo/v1/echo2": {
      "post": {
        "operationId": "EchoApi_echo2",
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "schema": {
              "$ref": "#/definitions/ProtorpcMessagesCombinedContainer"★not TEST_RESOURCE but ECHO_RESOURCE! 
            }
          }
        ],

是规格还是BUG? 每个API都可以定义ResourceContainer吗?

我找不到有关ResourceContainer的API参考。 参考页面在哪里?

1 个答案:

答案 0 :(得分:0)

如果没有看到完整的例子,很难说,但我怀疑原因是你从未使用'测试'任何请求中的属性;你不接受考试' url参数。