If you go to http://localhost:8080/_ah/api/discovery/v1/apis/user/v1/rest
you'll see the discovery document generated by your API. Note that (toward the bottom) the create
method on the user
resource is shown as taking a BaseModel
rather than a User
.
Now I don't know why this happens precisely—it's definitely related to the magic being done by EndpointsModel—but I have been able to achieve the result you want by switching the inheritance around, and treating BaseModel
like a mixin rather than a base class, this way the User
model can inherit directly from EndpointsModel
:
class BaseModel:
created_at = ndb.DateTimeProperty(auto_now_add=True)
modified_at = ndb.DateTimeProperty(auto_now=True)
class User(BaseModel, EndpointsModel):
username = ndb.StringProperty(required=True)
It makes sense then to rename BaseModel
to something that makes more explicit it's a mixin now.
If you check the same discovery document (or API Explorer) you'll notice create
takes a User
message after this change.