Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4077d4f7
Commit
4077d4f7
authored
Jun 13, 2018
by
Jan
Committed by
Rémy Coutable
Jun 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Provide ability to retrieve `visibility` level via Snippets API"
parent
a0a6e38b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
2 deletions
+15
-2
changelogs/unreleased/35158-snippets-api-visibility.yml
changelogs/unreleased/35158-snippets-api-visibility.yml
+5
-0
doc/api/snippets.md
doc/api/snippets.md
+5
-1
lib/api/entities.rb
lib/api/entities.rb
+1
-1
spec/fixtures/api/schemas/public_api/v4/snippets.json
spec/fixtures/api/schemas/public_api/v4/snippets.json
+1
-0
spec/requests/api/snippets_spec.rb
spec/requests/api/snippets_spec.rb
+3
-0
No files found.
changelogs/unreleased/35158-snippets-api-visibility.yml
0 → 100644
View file @
4077d4f7
---
title
:
Expose visibility via Snippets API
merge_request
:
19620
author
:
Jan Beckmann
type
:
added
doc/api/snippets.md
View file @
4077d4f7
...
...
@@ -49,6 +49,7 @@ Example response:
"title"
:
"test"
,
"file_name"
:
"add.rb"
,
"description"
:
"Ruby test snippet"
,
"visibility"
:
"private"
,
"author"
:
{
"id"
:
1
,
"username"
:
"john_smith"
,
...
...
@@ -99,6 +100,7 @@ Example response:
"title"
:
"This is a snippet"
,
"file_name"
:
"test.txt"
,
"description"
:
"Hello World snippet"
,
"visibility"
:
"internal"
,
"author"
:
{
"id"
:
1
,
"username"
:
"john_smith"
,
...
...
@@ -150,6 +152,7 @@ Example response:
"title"
:
"test"
,
"file_name"
:
"add.rb"
,
"description"
:
"description of snippet"
,
"visibility"
:
"internal"
,
"author"
:
{
"id"
:
1
,
"username"
:
"john_smith"
,
...
...
@@ -238,7 +241,8 @@ Example response:
"raw_url"
:
"http://localhost:3000/snippets/48/raw"
,
"title"
:
"Minus similique nesciunt vel fugiat qui ullam sunt."
,
"updated_at"
:
"2016-11-25T16:53:34.479Z"
,
"web_url"
:
"http://localhost:3000/snippets/48"
"web_url"
:
"http://localhost:3000/snippets/48"
,
"visibility"
:
"public"
}
]
```
...
...
lib/api/entities.rb
View file @
4077d4f7
...
...
@@ -362,7 +362,7 @@ module API
end
class
Snippet
<
Grape
::
Entity
expose
:id
,
:title
,
:file_name
,
:description
expose
:id
,
:title
,
:file_name
,
:description
,
:visibility
expose
:author
,
using:
Entities
::
UserBasic
expose
:updated_at
,
:created_at
expose
:project_id
...
...
spec/fixtures/api/schemas/public_api/v4/snippets.json
View file @
4077d4f7
...
...
@@ -8,6 +8,7 @@
"title"
:
{
"type"
:
"string"
},
"file_name"
:
{
"type"
:
[
"string"
,
"null"
]
},
"description"
:
{
"type"
:
[
"string"
,
"null"
]
},
"visibility"
:
{
"type"
:
"string"
},
"web_url"
:
{
"type"
:
"string"
},
"created_at"
:
{
"type"
:
"date"
},
"updated_at"
:
{
"type"
:
"date"
},
...
...
spec/requests/api/snippets_spec.rb
View file @
4077d4f7
...
...
@@ -20,6 +20,7 @@ describe API::Snippets do
private_snippet
.
id
)
expect
(
json_response
.
last
).
to
have_key
(
'web_url'
)
expect
(
json_response
.
last
).
to
have_key
(
'raw_url'
)
expect
(
json_response
.
last
).
to
have_key
(
'visibility'
)
end
it
'hides private snippets from regular user'
do
...
...
@@ -112,6 +113,7 @@ describe API::Snippets do
expect
(
json_response
[
'title'
]).
to
eq
(
snippet
.
title
)
expect
(
json_response
[
'description'
]).
to
eq
(
snippet
.
description
)
expect
(
json_response
[
'file_name'
]).
to
eq
(
snippet
.
file_name
)
expect
(
json_response
[
'visibility'
]).
to
eq
(
snippet
.
visibility
)
end
it
'returns 404 for invalid snippet id'
do
...
...
@@ -142,6 +144,7 @@ describe API::Snippets do
expect
(
json_response
[
'title'
]).
to
eq
(
params
[
:title
])
expect
(
json_response
[
'description'
]).
to
eq
(
params
[
:description
])
expect
(
json_response
[
'file_name'
]).
to
eq
(
params
[
:file_name
])
expect
(
json_response
[
'visibility'
]).
to
eq
(
params
[
:visibility
])
end
it
'returns 400 for missing parameters'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment