diff options
Diffstat (limited to 'lib/api/entities/snippet.rb')
-rw-r--r-- | lib/api/entities/snippet.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/api/entities/snippet.rb b/lib/api/entities/snippet.rb index 8a13b4746a9..19c89603cbc 100644 --- a/lib/api/entities/snippet.rb +++ b/lib/api/entities/snippet.rb @@ -3,14 +3,20 @@ module API module Entities class Snippet < Grape::Entity - expose :id, :title, :file_name, :description, :visibility + expose :id, :title, :description, :visibility expose :author, using: Entities::UserBasic expose :updated_at, :created_at expose :project_id expose :web_url do |snippet| Gitlab::UrlBuilder.build(snippet) end - expose :ssh_url_to_repo, :http_url_to_repo, if: ->(snippet) { snippet.versioned_enabled_for?(options[:current_user]) } + 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 end end end |