diff options
author | Toon Claes <toon@gitlab.com> | 2017-02-16 18:42:17 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-03-02 14:15:24 +0300 |
commit | 209856166e822aff46a7f9a5000896720e273265 (patch) | |
tree | fd11c9471eea9aa43293f020242fa1481dd7a06d /lib/api/snippets.rb | |
parent | ed8f13c745da849c319eb8e9d8fd3e59bb804a08 (diff) |
Expose Snippet VisibilityLevel as String
Diffstat (limited to 'lib/api/snippets.rb')
-rw-r--r-- | lib/api/snippets.rb | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb index 0f86fdb3075..c5e55a5df4f 100644 --- a/lib/api/snippets.rb +++ b/lib/api/snippets.rb @@ -58,13 +58,13 @@ module API requires :title, type: String, desc: 'The title of a snippet' requires :file_name, type: String, desc: 'The name of a snippet file' requires :content, type: String, desc: 'The content of a snippet' - optional :visibility_level, type: Integer, - values: Gitlab::VisibilityLevel.values, - default: Gitlab::VisibilityLevel::INTERNAL, - desc: 'The visibility level of the snippet' + optional :visibility, type: String, + values: Gitlab::VisibilityLevel.string_values, + default: 'internal', + desc: 'The visibility of the snippet' end post do - attrs = declared_params(include_missing: false).merge(request: request, api: true) + attrs = map_visibility_level(declared_params(include_missing: false)).merge(request: request, api: true) snippet = CreateSnippetService.new(nil, current_user, attrs).execute render_spam_error! if snippet.spam? @@ -85,17 +85,17 @@ module API optional :title, type: String, desc: 'The title of a snippet' optional :file_name, type: String, desc: 'The name of a snippet file' optional :content, type: String, desc: 'The content of a snippet' - optional :visibility_level, type: Integer, - values: Gitlab::VisibilityLevel.values, - desc: 'The visibility level of the snippet' - at_least_one_of :title, :file_name, :content, :visibility_level + optional :visibility, type: String, + values: Gitlab::VisibilityLevel.string_values, + desc: 'The visibility of the snippet' + at_least_one_of :title, :file_name, :content, :visibility end put ':id' do snippet = snippets_for_current_user.find_by(id: params.delete(:id)) return not_found!('Snippet') unless snippet authorize! :update_personal_snippet, snippet - attrs = declared_params(include_missing: false).merge(request: request, api: true) + attrs = map_visibility_level(declared_params(include_missing: false).merge(request: request, api: true)) UpdateSnippetService.new(nil, current_user, snippet, attrs).execute |