Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
4077d4f7
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4077d4f7
编写于
6月 13, 2018
作者:
J
Jan
提交者:
Rémy Coutable
6月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resolve "Provide ability to retrieve `visibility` level via Snippets API"
上级
a0a6e38b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
2 deletion
+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
未找到文件。
changelogs/unreleased/35158-snippets-api-visibility.yml
0 → 100644
浏览文件 @
4077d4f7
---
title
:
Expose visibility via Snippets API
merge_request
:
19620
author
:
Jan Beckmann
type
:
added
doc/api/snippets.md
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录