Skip to content

Commit

Permalink
fix: /erm/entitlements API returns invalid JSON data (#847)
Browse files Browse the repository at this point in the history
* fix: /erm/entitlements API returns invalid JSON data

Originally the erm/entitlements endpoint would return invalid JSON on an agreement with > 2 agreement lines and a usageDataProvider, due to an inherent bug within the grails-views plugin, the usageDataProvider view gson is now more explicitly typed to prevent this

ERM-3464

* fix: usageDataProviderNote

Fixed a stupid mistake attempting to render a string
  • Loading branch information
Jack-Golding authored Dec 20, 2024
1 parent 12120c1 commit 7570a4f
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions service/grails-app/views/usageDataProvider/_usageDataProvider.gson
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import org.olf.erm.UsageDataProvider

inherits template: "/remoteOkapiLink/remoteOkapiLink"

def should_expand = ['usageDataProviderNote']
json {
if (usageDataProvider.usageDataProviderNote){
'usageDataProviderNote' usageDataProvider.usageDataProviderNote
}

if (params.controller == 'usageDataProvider' ) {
should_expand << 'owner'
if (params.controller == 'usageDataProvider') {
'owner' g.render( usageDataProvider.owner )
} else {
'owner' {
'id' usageDataProvider.owner.id
}
}
}

json g.render(usageDataProvider, ['excludes': ['id', 'version', 'remoteId'], 'expand':should_expand])

0 comments on commit 7570a4f

Please sign in to comment.