debian-mirror-gitlab/lib/api/entities/issue_basic.rb

55 lines
2.1 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
module API
module Entities
class IssueBasic < IssuableEntity
2021-06-08 01:23:25 +05:30
format_with(:upcase) do |item|
item.upcase if item.respond_to?(:upcase)
end
2023-01-13 00:05:48 +05:30
expose :closed_at, documentation: { type: 'dateTime', example: '2022-11-15T08:30:55.232Z' }
2020-03-13 15:44:24 +05:30
expose :closed_by, using: Entities::UserBasic
2023-01-13 00:05:48 +05:30
expose :labels, documentation: { type: 'string', is_array: true, example: 'bug' } do |issue, options|
2020-03-13 15:44:24 +05:30
if options[:with_labels_details]
::API::Entities::LabelBasic.represent(issue.labels.sort_by(&:title))
else
issue.labels.map(&:title).sort
end
end
expose :milestone, using: Entities::Milestone
expose :assignees, :author, using: Entities::UserBasic
2021-06-08 01:23:25 +05:30
expose :issue_type,
as: :type,
format_with: :upcase,
2023-01-13 00:05:48 +05:30
documentation: { type: 'String', example: 'ISSUE', desc: "One of #{::WorkItems::Type.allowed_types_for_issues.map(&:upcase)}" }
2020-03-13 15:44:24 +05:30
expose :assignee, using: ::API::Entities::UserBasic do |issue|
issue.assignees.first
end
2020-07-28 23:09:34 +05:30
expose(:user_notes_count) { |issue, options| issuable_metadata.user_notes_count }
expose(:merge_requests_count) { |issue, options| issuable_metadata.merge_requests_count }
expose(:upvotes) { |issue, options| issuable_metadata.upvotes }
expose(:downvotes) { |issue, options| issuable_metadata.downvotes }
2023-01-13 00:05:48 +05:30
expose :due_date, documentation: { type: 'date', example: '2022-11-20' }
expose :confidential, documentation: { type: 'boolean' }
expose :discussion_locked, documentation: { type: 'boolean' }
expose :issue_type, documentation: { type: 'string', example: 'issue' }
2020-03-13 15:44:24 +05:30
2023-01-13 00:05:48 +05:30
expose :web_url, documentation: { type: 'string', example: 'http://example.com/example/example/issues/14' } do |issue|
2020-03-13 15:44:24 +05:30
Gitlab::UrlBuilder.build(issue)
end
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
issue
end
expose :task_completion_status
end
end
end
2021-06-08 01:23:25 +05:30
API::Entities::IssueBasic.prepend_mod_with('API::Entities::IssueBasic', with_descendants: true)