Commit 3652e284 authored by Nick Thomas's avatar Nick Thomas

Merge branch '35527-add-group-package-api-fields' into 'master'

Adds project_id and project_path to group api

See merge request gitlab-org/gitlab!22089
parents 8bd5a3d3 7da454c5
---
title: Adds project_id and project_path to package group api
merge_request: 22089
author:
type: added
...@@ -29,7 +29,7 @@ module API ...@@ -29,7 +29,7 @@ module API
exclude_subgroups: params[:exclude_subgroups] exclude_subgroups: params[:exclude_subgroups]
).execute ).execute
present paginate(packages), with: EE::API::Entities::Package present paginate(packages), with: EE::API::Entities::Package, user: current_user, group: true
end end
end end
end end
......
...@@ -891,6 +891,14 @@ module EE ...@@ -891,6 +891,14 @@ module EE
end end
expose :created_at expose :created_at
expose :project_id, if: ->(_, opts) { opts[:group] }
expose :project_path, if: ->(obj, opts) { opts[:group] && Ability.allowed?(opts[:user], :read_project, obj.project) }
private
def project_path
object.project.full_path
end
end end
class PackageFile < Grape::Entity class PackageFile < Grape::Entity
......
{
"type": "object",
"required": ["name", "version", "package_type", "_links", "project_id", "project_path"],
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"package_type": {
"type": "string"
},
"_links": {
"type": "object",
"required": ["web_path"],
"properties": {
"details": {
"type": "string"
}
}
},
"created_at": {
"type": "string"
},
"project_id": {
"type": "integer"
},
"project_path": {
"type": "string"
}
}
}
{
"type": "array",
"items": { "$ref": "./group_package.json" }
}
...@@ -13,6 +13,7 @@ describe API::GroupPackages do ...@@ -13,6 +13,7 @@ describe API::GroupPackages do
describe 'GET /groups/:id/packages' do describe 'GET /groups/:id/packages' do
let(:url) { "/groups/#{group.id}/packages" } let(:url) { "/groups/#{group.id}/packages" }
let(:package_schema) { 'public_api/v4/packages/group_packages' }
context 'with packages feature enabled' do context 'with packages feature enabled' do
before do before do
......
...@@ -14,6 +14,7 @@ describe API::ProjectPackages do ...@@ -14,6 +14,7 @@ describe API::ProjectPackages do
describe 'GET /projects/:id/packages' do describe 'GET /projects/:id/packages' do
let(:url) { "/projects/#{project.id}/packages" } let(:url) { "/projects/#{project.id}/packages" }
let(:package_schema) { 'public_api/v4/packages/packages' }
subject { get api(url) } subject { get api(url) }
......
...@@ -29,7 +29,7 @@ shared_examples 'returns packages' do |container_type, user_type| ...@@ -29,7 +29,7 @@ shared_examples 'returns packages' do |container_type, user_type|
it 'returns a valid response schema' do it 'returns a valid response schema' do
subject subject
expect(response).to match_response_schema('public_api/v4/packages/packages', dir: 'ee') expect(response).to match_response_schema(package_schema, dir: 'ee')
end end
it 'returns two packages' do it 'returns two packages' do
...@@ -56,7 +56,7 @@ shared_examples 'returns packages with subgroups' do |container_type, user_type| ...@@ -56,7 +56,7 @@ shared_examples 'returns packages with subgroups' do |container_type, user_type|
it 'returns a valid response schema' do it 'returns a valid response schema' do
subject subject
expect(response).to match_response_schema('public_api/v4/packages/packages', dir: 'ee') expect(response).to match_response_schema(package_schema, dir: 'ee')
end end
it 'returns three packages' do it 'returns three packages' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment