Closed matdrapeau closed 6 years ago
{$ref}
objects usually stand alone. I am not sure I understand your question. Perhaps you want to use an Inline
instead of a ToOne
field?
Let say I have a resource with this schema:
class Schema:
title = fields.String()
description = fields.String()
users = fields.List(alchemy.fields.InlineModel( {
'name': fields.String(),
'email': fields.String(),
'$ref': ???},
model=User))
How can I add the reference to the User resource (such as '/user/1' by example) in this current schema without using fields.ToMany
since that users attribute should display more information than just a single '$ref'.
Or possibly, I wouldn't mind describing my schema such as:
class Schema:
title = fields.String()
description = fields.String()
users = fields.List(fields.ToMany('users'))
But how could I add 'name' and 'email' attributes to each users?
Have you tried users = fields.List(fields.Inline('user'))
?
That's working as expected with fields.Inline
thanks!
How can I add the refkey (usually seen as "$ref") to an sqlalchemy InlineModel field? Or if I want to add extra attributes to a ToOne field?