我想要一个端点来获取某种类型的对象并返回不同类型的对象,而不是让它们具有相同的类型。
例如:
class SomeClass(EndpointsModel):
name = ndb.StringProperty()
class OtherClass(EndpointsModel):
otherName = ndb.StringProperty()
@SomeClass.method(path='mymodel', http_method='POST', name='mymodel.insert')
def MyModelInsert(self, my_model):
my_model.put()
otherModel = OtherClass(otherName='someothername')
return otherModel
目前我得到:
ServerError (Method MyApi.MyModelInsert expected response type <class '.SomeClass'>, sent <class '.OtherClass'>)
有没有办法让输入 Class 与返回 Class 不同?