mikekelly / hal-browser

An API browser for the hal+json media type
MIT License
835 stars 157 forks source link

embedded resources not rendered if no curies are specified #71

Open ujibang opened 8 years ago

ujibang commented 8 years ago

I noticed that the HAL browser fails to render data if the curies 'section' is not present.

I think that a document without the curies section is still valid HAL since the formal HAL specification shows examples of documents without it.

In this case, the embedded and inspector sections are not shown at all.

An example follows:

This renders fine (also if _links.curies is an empty array):

{
  "_type": "COLLECTION",
  "_returned": 3,
  "_links": {
    "self": {
      "href": "/test/albums?hal=c"
    },
    "curies": [
      {
        "href": "http://restheart.org/curies/1.0/{rel}.html",
        "templated": true,
        "name": "rh"
      }
    ]
  },
  "_embedded": {
    "rh:doc": [
      {
        "_links": {
          "self": {
            "href": "/test/albums/Three Imaginary Boys"
          }
        },
        "_type": "DOCUMENT",
        "_id": "Three Imaginary Boys",
        "year": 1979,
        "_etag": {
          "$oid": "55f1601ec2e65448b566d18f"
        }
      },
      {
        "_links": {
          "self": {
            "href": "/test/albums/Seventeen Seconds"
          }
        },
        "_type": "DOCUMENT",
        "_id": "Seventeen Seconds",
        "year": 1980,
        "_etag": {
          "$oid": "55f16023c2e65448b566d190"
        }
      },
      {
        "_links": {
          "self": {
            "href": "/test/albums/Disintegration"
          }
        },
        "_type": "DOCUMENT",
        "_id": "Disintegration",
        "year": 1989,
        "_etag": {
          "$oid": "55f16015c2e65448b566d18e"
        }
      }
    ]
  }
}

This doesn't: the embedded and inspector sections are not rendered! (note that the curies property is missing):

{
    "_returned": 3, 
    "_type": "COLLECTION",
    "_links": {
        "self": {
            "href": "/test/albums?hal=c"
        }
    },
    "_embedded": {
        "rh:doc": [
            {
                "_etag": {
                    "$oid": "55f1601ec2e65448b566d18f"
                }, 
                "_id": "Three Imaginary Boys", 
                "_links": {
                    "self": {
                        "href": "/test/albums/Three Imaginary Boys"
                    }
                }, 
                "_type": "DOCUMENT", 
                "year": 1979
            }, 
            {
                "_etag": {
                    "$oid": "55f16023c2e65448b566d190"
                }, 
                "_id": "Seventeen Seconds", 
                "_links": {
                    "self": {
                        "href": "/test/albums/Seventeen Seconds"
                    }
                }, 
                "_type": "DOCUMENT", 
                "year": 1980
            }, 
            {
                "_etag": {
                    "$oid": "55f16015c2e65448b566d18e"
                }, 
                "_id": "Disintegration", 
                "_links": {
                    "self": {
                        "href": "/test/albums/Disintegration"
                    }
                }, 
                "_type": "DOCUMENT", 
                "year": 1989
            }
        ]
    }
}
drdamour commented 8 years ago

same as #79