From 209856166e822aff46a7f9a5000896720e273265 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Thu, 16 Feb 2017 16:42:17 +0100 Subject: Expose Snippet VisibilityLevel as String --- lib/api/snippets.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/api/snippets.rb') 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 -- cgit v1.2.1