gpt4 book ai didi

python - Endpoints API - protopc 验证错误

转载 作者:IT老高 更新时间:2023-10-28 22:05:48 26 4
gpt4 key购买 nike

我从 protorpc 收到一些奇怪的错误当我使用端点时。在这段代码中:

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

当我调用 application.get() 时错误如下:(full trace here):

TypeError: Can only copy from entities of the exact type Application. Received an instance of Application.

以及调用 application.list()错误如下:(full trace here):

ValidationError: Expected type <class '.Application'> for field items, found <Application name: u'test'> (type <class '.Application'>)

这可能是什么原因造成的?我的其他具有几乎相同代码(只是属性不同)的模型工作正常。

最佳答案

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

关于python - Endpoints API - protopc 验证错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35540265/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com