diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-02-14 10:40:59 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-02-14 10:40:59 +0000 |
commit | 6085656bffa54cdbe21e776e283f87ece313991f (patch) | |
tree | 0798db9f44217da4ff340ab66844673e5e189839 /lib/api/entities.rb | |
parent | 5e829934f95bcae25f5c09583b6febe6e2e646b6 (diff) | |
parent | b7cd99c376c2f953f30a4bf982b69780e3d6985b (diff) | |
download | gitlab-ce-6085656bffa54cdbe21e776e283f87ece313991f.tar.gz |
Merge branch 'feature/include-custom-attributes-in-api' into 'master'
Allow including custom attributes in API responses
See merge request gitlab-org/gitlab-ce!16526
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r-- | lib/api/entities.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e9e32ac76fe..03abc1b95c5 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -22,6 +22,7 @@ module API end expose :avatar_path, if: ->(user, options) { options.fetch(:only_path, false) && user.avatar_path } + expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes expose :web_url do |user, options| Gitlab::Routing.url_helpers.user_url(user) @@ -109,6 +110,8 @@ module API expose :star_count, :forks_count expose :last_activity_at + expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes + def self.preload_relation(projects_relation, options = {}) projects_relation.preload(:project_feature, :route) .preload(namespace: [:route, :owner], @@ -230,6 +233,8 @@ module API expose :parent_id end + expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes + expose :statistics, if: :statistics do with_options format_with: -> (value) { value.to_i } do expose :storage_size |