Skip to main content
replaced https://tools.ietf.org/html/draft with https://datatracker.ietf.org/doc/html/draft
Source Link

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, Hypertext Application Language. Here is an example:

GET /recommendations HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "_links": {
    "self": { "href": "/recommendations" },
    "next": { "href": "/recommendations?page=2" },
    "find": { "href": "/recommendations{?id}", "templated": true }
},
"_embedded": {
    "recommendations": [{
        "_links": {
            "self": { "href": "/recommendations/123" },
            "users": { "href": "/users/98712" },
            "companies": { "href": "/companies/7809" }
       },
     },{
         "_links": {
             "self": { "href": "/recommendations/124" },
             "users": { "href": "/users/97213" },
             "companies": { "href": "/companies/12369" }
         },
    }]
},
}

Copied from ExampleDocumentExampleDocument

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, Hypertext Application Language. Here is an example:

GET /recommendations HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "_links": {
    "self": { "href": "/recommendations" },
    "next": { "href": "/recommendations?page=2" },
    "find": { "href": "/recommendations{?id}", "templated": true }
},
"_embedded": {
    "recommendations": [{
        "_links": {
            "self": { "href": "/recommendations/123" },
            "users": { "href": "/users/98712" },
            "companies": { "href": "/companies/7809" }
       },
     },{
         "_links": {
             "self": { "href": "/recommendations/124" },
             "users": { "href": "/users/97213" },
             "companies": { "href": "/companies/12369" }
         },
    }]
},
}

Copied from ExampleDocument

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, Hypertext Application Language. Here is an example:

GET /recommendations HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "_links": {
    "self": { "href": "/recommendations" },
    "next": { "href": "/recommendations?page=2" },
    "find": { "href": "/recommendations{?id}", "templated": true }
},
"_embedded": {
    "recommendations": [{
        "_links": {
            "self": { "href": "/recommendations/123" },
            "users": { "href": "/users/98712" },
            "companies": { "href": "/companies/7809" }
       },
     },{
         "_links": {
             "self": { "href": "/recommendations/124" },
             "users": { "href": "/users/97213" },
             "companies": { "href": "/companies/12369" }
         },
    }]
},
}

Copied from ExampleDocument

add example and link to standard
Source Link
imel96
  • 3.6k
  • 1
  • 21
  • 28

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, HALHypertext Application Language. Have a look atHere is an example:

GET /recommendations HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "_links": {
    "self": { "href": "/recommendations" },
    "next": { "href": "/recommendations?page=2" },
    "find": { "href": "/recommendations{?id}", "templated": true }
},
"_embedded": {
    "recommendations": [{
        "_links": {
            "self": { "href": "/recommendations/123" },
            "users": { "href": "/users/98712" },
            "companies": { "href": "/companies/7809" }
       },
     },{
         "_links": {
             "self": { "href": "/recommendations/124" },
             "users": { "href": "/users/97213" },
             "companies": { "href": "/companies/12369" }
         },
    }]
},
}

Copied from http://stateless.co/hal_specification.htmlExampleDocument

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, HAL. Have a look at http://stateless.co/hal_specification.html

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, Hypertext Application Language. Here is an example:

GET /recommendations HTTP/1.1
Host: example.org
Accept: application/hal+json

HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "_links": {
    "self": { "href": "/recommendations" },
    "next": { "href": "/recommendations?page=2" },
    "find": { "href": "/recommendations{?id}", "templated": true }
},
"_embedded": {
    "recommendations": [{
        "_links": {
            "self": { "href": "/recommendations/123" },
            "users": { "href": "/users/98712" },
            "companies": { "href": "/companies/7809" }
       },
     },{
         "_links": {
             "self": { "href": "/recommendations/124" },
             "users": { "href": "/users/97213" },
             "companies": { "href": "/companies/12369" }
         },
    }]
},
}

Copied from ExampleDocument

Source Link
imel96
  • 3.6k
  • 1
  • 21
  • 28

Without making assumptions about relationships between Company and User, I think you just want a nice way to return composition of different type of objects. There's a proposed standard that pretty well defines how to do this, HAL. Have a look at http://stateless.co/hal_specification.html