From 3c5eddc1bd507ee96404f226b8391cf3e4e98050 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Fri, 1 Oct 2021 11:57:44 -0500 Subject: [PATCH] add id in GET /metadata.jsonld responses (#279) * add id * add entry in changelog issue #278 * reordering the field to make id second Co-authored-by: Luigi Marini --- CHANGELOG.md | 1 + app/util/JSONLD.scala | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de0df3a32..fbb577f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Adding mime type for geojson - Add "when" parameter in a few GET API endpoints to enable pagination [#266](https://github.com/clowder-framework/clowder/issues/266) +- Add "id" in GET metadata.jsonld endpoints [#278](https://github.com/clowder-framework/clowder/issues/278) ## 1.18.1 - 2021-08-16 diff --git a/app/util/JSONLD.scala b/app/util/JSONLD.scala index c45dca24d..3eacc7214 100644 --- a/app/util/JSONLD.scala +++ b/app/util/JSONLD.scala @@ -63,7 +63,8 @@ object JSONLD { ) //convert metadata to json using implicit writes in Metadata model - val metadataJson = resourceJson ++ toJson(metadata).asInstanceOf[JsObject] + //include metadata ID in the json + val metadataJson = JsObject(Seq("id" -> JsString(metadata.id.toString()))) ++ resourceJson ++ toJson(metadata).asInstanceOf[JsObject] //combine the two json objects and return if (contextJson.isEmpty) metadataJson else contextJson.get ++ metadataJson