Skip to content

Commit

Permalink
add id in GET /metadata.jsonld responses (#279)
Browse files Browse the repository at this point in the history
* add id

* add entry in changelog issue #278

* reordering the field to make id second

Co-authored-by: Luigi Marini <lmarini@users.noreply.github.com>
  • Loading branch information
longshuicy and lmarini committed Oct 1, 2021
1 parent d25f2a4 commit 3c5eddc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion app/util/JSONLD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3c5eddc

Please sign in to comment.