api-platform / api-platform/core

Json HAL: URI template implementation

Đang mở
#2,120 1 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
2.6k
Fork
980
Merge trung bình
2 ngày 5 giờ
Pull request đã merge (30 ngày)
48

Mô tả

First, thank you for this amazing project that saved me a lot of time to create my API!

For my VueJS application, i would like to implement an auto discoverable API with HATEOAS + JSON HAL (imposed for an educational project).

In my client side, i use [Traverson](https://github.com/traverson/traverson ) to request my API but without URI template i can't fetch a document with an ID parameter.

_https://github.com/traverson/traverson/blob/master/user-guide.markdown#uri-templates_

traverson

.from('https://demo.api-platform.com/')
.follow('book', 'article')
.jsonHal()
.withTemplateParameters({ id: 1 })
.getResource(function(error, doc) {
...
});

_https://demo.api-platform.com/books.jsonhal_

{

"_links": {
"self": {
"href": "\/books.jsonhal?page=1"
},
"first": {
"href": "\/books.jsonhal?page=1"
},
"last": {
"href": "\/books.jsonhal?page=4"
},
"next": {
"href": "\/books.jsonhal?page=2"
},
"item": [{
"href": "\/books\/1"
}, {
"href": "\/books\/2"
}]
},
...
}

With URI template it would be something like:

{

"_links": {
"self": {
"href": "\/books.jsonhal?page=1"
},
"first": {
"href": "\/books.jsonhal?page=1"
},
"last": {
"href": "\/books.jsonhal?page=4"
},
"next": {
"href": "\/books.jsonhal?page=2"
},
"article": "\/articles\/{id}",
"item": [{
"href": "\/books\/1"
}, {
"href": "\/books\/2"
}]
},
...
}

At the moment, i've not found a way to request the API without providing the URI to fetch a document (collection it's okey).
Are URI templates planned to be implemented ?

Thanks

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.