Hi all,
Thanks all and specially Kevin for this amazing project, I am working in a internal project and we decided to go full power into the direction of a Restful interface, and after some research our specification of choice to help us to model our API is Siren.
But I would like some advice from the experts here. Probably my problem was already solved many times by you so probably you already have some best practices. I have an entity like this:
{
"class": [
"list"
],
"entities": [
{
"class": [
"cardSetup"
],
"rel": [
"item"
],
"properties": {
"name": "NFC_virtual_card_CH"
},
"entities": [
{
"rel": [
"paymentCard"
],
"href": "/admin/brands/mywirecard2go/model/payment-cards/NFC_virtual_card_CH",
"title": "Payment Card"
}
]
}
],
"actions": [
{
"name": "create",
"method": "POST",
"href": "/admin/brands/mywirecard2go/model/card-setups",
"type": "application/vnd.wirecard.brand.admin-v1+json"
}
],
"links": [
{
"rel": [
"self"
],
"href": "/admin/brands/mywirecard2go/model/card-setups"
}
]
}
Basically as now the entity has a name and an associated entity to it. What I would like to know is how are you guys doing to model the actions to allow, in a machine-understandable way, to create a new entity associated with another already existing entity, how to update, etc...
A friend of us from the siren4j project added some custom attributes to fields, some of them make a lot sense for me, but I would like to discuss how this is seen by the fathers of the specification. For example the "options" attribute or the "optionsURL", see some of the documentation here:
https://github.com/eserating/siren4j/wiki/Siren4JAnnotations.
From what I understood I could add in my create action something like that:
...
"fields":[
{
"name": "paymentCard",
"optionsURL": "/admin/brands/mywirecard2go/model/payment-cards"
}
...
]
...
What looks ok-ish, but than how to describe what attribute should be considered the id in the related entity? I can do it by convention, forcing to always have a attribute with the name "id" as the json:api does, or I can add a metadata section to my entity describing that.
But none of than, the fields above and my solution with metadata is described by the specification, so looks like I am taking the wrong direction, can you help me clarifying or giving some examples of similar problems solved by you?
Thanks!