New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow list of Hyperlinks #11
Comments
I suppose we could support arrays of links with a |
I figured I'd try and contribute and implement this, but it seems it already works as is. No work needed. I added this test code to start with and it passed.
|
@Kareeeeem I believe the problem is that lists containing Here is a failing test: def test_hyperlinks_field_recurses_into_list(ma, mockauthor):
field = ma.Hyperlinks([
{'rel': 'self', 'href': ma.URLFor('author', id='<id>')},
{'rel': 'collection', 'href': ma.URLFor('authors')}
])
result = field.serialize('_links', mockauthor)
assert result == [
{'rel': 'self', 'href': url_for('author', id=mockauthor.id)},
{'rel': 'collection', 'href': url_for('authors')}
] I believe the implementation will be simpler than I originally thought; will add this soon. |
Currently there is no way to create an array/list of hyperlinks, as it expects a dict. A common format for hateoas is as this: https://developer.paypal.com/docs/api/#hateoas-links
"links" : [{
"href" : "https://api.sandbox.paypal.com/v1/payments/payment/PAY-2XR800907F429382MKEBWOSA",
"rel" : "self",
"method" : "GET"
}, {
"href" : "https://api.sandbox.paypal.com/v1/payments/payment/PAY-2XR800907F429382MKEBWOSA/execute",
"rel" : "update",
"method" : "POST"
This format provides standard keys for every link, and is therefore easier to navigate.
The text was updated successfully, but these errors were encountered: