简体   繁体   English

端点API - protorpc验证错误

[英]Endpoints API - protorpc validation error

I'm getting some weird errors from protorpc when I use endpoints. 当我使用端点时,我从protorpc得到了一些奇怪的错误。 In this code: 在这段代码中:

class Application(EndpointsModel):

    _message_fields_schema = ('id', 'name')

    created = ndb.DateTimeProperty(auto_now_add=True)
    name = ndb.StringProperty()
    roles = ndb.IntegerProperty(repeated=True)
    updated = ndb.DateTimeProperty(auto_now=True)
    owner = ndb.KeyProperty(kind='User')

@API.api_class(resource_name="application")
class ApplicationApi(protorpc.remote.Service):

    @Application.method(http_method="GET",
                        request_fields=('id',),
                        name="get",
                        path="applications/{id}")
    def ApplicationGet(self, instance):
        if not instance.from_datastore:
            raise endpoints.NotFoundException("Application not found.")
        return instance

    @Application.query_method(http_method="GET",
                              query_fields=('limit', 'order', 'pageToken'),
                              name="list",
                              path="applications")
    def ApplicationList(self, query):
        return query

when I call application.get() error is as follows: ( full trace here ): 当我调用application.get()出现如下错误:( 完全跟踪 ):

TypeError: Can only copy from entities of the exact type Application. TypeError:只能从确切类型为Application的实体进行复制。 Received an instance of Application. 收到了一个Application实例。

and for calling application.list() error is as follows: ( full trace here ): 并且用于调用application.list()错误如下:( 完全跟踪 ):

ValidationError: Expected type <class '.Application'> for field items, found <Application name: u'test'> (type <class '.Application'> ) ValidationError:字段项的预期类型<class '.Application'> <Application name: u'test'> ,找到<Application name: u'test'> (type <class '.Application'> <Application name: u'test'> <class '.Application'>

What could be causing this? 可能是什么导致了这个? My other models with pretty much the same code (just different properties) work fine. 我的其他模型具有几乎相同的代码(只是不同的属性)工作正常。

class JsonModel(EndpointsModel)使其重新开始工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM