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

33 lines
1.5 KiB
Ruby
Raw Normal View History

2021-03-08 18:12:59 +05:30
# frozen_string_literal: true
module API
module Entities
class BasicSnippet < Grape::Entity
2023-01-13 00:05:48 +05:30
expose :id, documentation: { type: 'integer', example: 1 }
expose :title, documentation: { type: 'string', example: 'test' }
expose :description, documentation: { type: 'string', example: 'Ruby test snippet' }
expose :visibility, documentation: { type: 'string', example: 'public' }
expose :author, using: Entities::UserBasic, documentation: { type: 'Entities::UserBasic' }
expose :created_at, documentation: { type: 'dateTime', example: '2012-06-28T10:52:04Z' }
expose :updated_at, documentation: { type: 'dateTime', example: '2012-06-28T10:52:04Z' }
expose :project_id, documentation: { type: 'integer', example: 1 }
expose :web_url, documentation: {
type: 'string', example: 'http://example.com/example/example/snippets/1'
} do |snippet|
2021-03-08 18:12:59 +05:30
Gitlab::UrlBuilder.build(snippet)
end
2023-01-13 00:05:48 +05:30
expose :raw_url, documentation: {
type: 'string', example: 'http://example.com/example/example/snippets/1/raw'
} do |snippet|
2021-03-08 18:12:59 +05:30
Gitlab::UrlBuilder.build(snippet, raw: true)
end
2023-01-13 00:05:48 +05:30
expose :ssh_url_to_repo, documentation: {
type: 'string', example: 'ssh://user@gitlab.example.com/snippets/65.git'
}, if: ->(snippet) { snippet.repository_exists? }
expose :http_url_to_repo, documentation: {
type: 'string', example: 'https://gitlab.example.com/snippets/65.git'
}, if: ->(snippet) { snippet.repository_exists? }
2021-03-08 18:12:59 +05:30
end
end
end