I would like to marshal an object so that I get a response containing a list of links using Url, List and Nested from the Flask-Restful api.
job_link_fields = {
'href': restful.fields.Url('ep1', absolute=False),
'rel': restful.fields.Url('ep2', absolute=False)
}
job_fields = {
'name': restful.fields.String,
'links': restful.fields.List(restful.fields.Nested(job_link_fields))
}
class JobDao():
def __init__(self, id, job):
self.name = job['name']
self.links = [{'rel': 'jobs', 'id': id},
{'rel': 'jobs', 'id': id}]
class Job(restful.Resource):
@marshal_with(job_fields)
def get(self, id):
return JobDao(id, jobs[id-1])
But in the Url class, I need to specify the endpoint in the constructor which prevents me from adding differend job_link_fields in the List. How can I create a list of link?