diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2017-07-25 09:35:45 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-07-25 09:35:45 +0000 |
commit | 33dc5171e5885bbc1de1db7b9be58453edfa9453 (patch) | |
tree | 70953a20215c456e1007a0df3849db00a98cbe34 /lib/api/v3 | |
parent | d5801545ec25780402c30c4d30d4efa16f0728a4 (diff) | |
download | gitlab-ce-33dc5171e5885bbc1de1db7b9be58453edfa9453.tar.gz |
Resolve "More RESTful API: include resource URLs in responses"
Diffstat (limited to 'lib/api/v3')
-rw-r--r-- | lib/api/v3/entities.rb | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/api/v3/entities.rb b/lib/api/v3/entities.rb index 3759250f7f6..773f667abe0 100644 --- a/lib/api/v3/entities.rb +++ b/lib/api/v3/entities.rb @@ -259,11 +259,40 @@ module API expose :job_events, as: :build_events end - class Issue < ::API::Entities::Issue + class ProjectEntity < Grape::Entity + expose :id, :iid + expose(:project_id) { |entity| entity&.project.try(:id) } + expose :title, :description + expose :state, :created_at, :updated_at + end + + class IssueBasic < ProjectEntity + expose :label_names, as: :labels + expose :milestone, using: ::API::Entities::Milestone + expose :assignees, :author, using: ::API::Entities::UserBasic + + expose :assignee, using: ::API::Entities::UserBasic do |issue, options| + issue.assignees.first + end + + expose :user_notes_count + expose :upvotes, :downvotes + expose :due_date + expose :confidential + + expose :web_url do |issue, options| + Gitlab::UrlBuilder.build(issue) + end + end + + class Issue < IssueBasic unexpose :assignees expose :assignee do |issue, options| ::API::Entities::UserBasic.represent(issue.assignees.first, options) end + expose :subscribed do |issue, options| + issue.subscribed?(options[:current_user], options[:project] || issue.project) + end end end end |