2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class Snippet < Grape::Entity
|
2020-05-24 23:13:21 +05:30
|
|
|
expose :id, :title, :description, :visibility
|
2020-03-13 15:44:24 +05:30
|
|
|
expose :author, using: Entities::UserBasic
|
|
|
|
expose :updated_at, :created_at
|
|
|
|
expose :project_id
|
|
|
|
expose :web_url do |snippet|
|
|
|
|
Gitlab::UrlBuilder.build(snippet)
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
expose :raw_url do |snippet|
|
|
|
|
Gitlab::UrlBuilder.build(snippet, raw: true)
|
|
|
|
end
|
|
|
|
expose :ssh_url_to_repo, :http_url_to_repo, if: ->(snippet) { snippet.repository_exists? }
|
|
|
|
expose :file_name do |snippet|
|
|
|
|
snippet.file_name_on_repo || snippet.file_name
|
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|