diff --git a/config/feature_flags/development/api_json_content_type.yml b/config/feature_flags/development/api_json_content_type.yml new file mode 100644 index 0000000000000000000000000000000000000000..bd153550635b5b474ab22060f1f89d27be749e01 --- /dev/null +++ b/config/feature_flags/development/api_json_content_type.yml @@ -0,0 +1,7 @@ +--- +name: api_json_content_type +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42229 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/270067 +group: group::ecosystem +type: development +default_enabled: false diff --git a/lib/api/api.rb b/lib/api/api.rb index 417d4d66aca2662247690183dc611911a784ef90..4300477bdb2d55c69740f0661d651b3b5eca2ea2 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -115,7 +115,14 @@ class API < Grape::API::Instance format :json formatter :json, Gitlab::Json::GrapeFormatter - content_type :txt, "text/plain" + + # There is a small chance some users depend on the old behavior. + # We this change under a feature flag to see if affects GitLab.com users. + if Feature.enabled?(:api_json_content_type) + content_type :json, 'application/json' + else + content_type :txt, 'text/plain' + end # Ensure the namespace is right, otherwise we might load Grape::API::Helpers helpers ::API::Helpers diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb index f86e18676c14cbb53b4de72397327d7d307ed629..9d2e251caf826180eb0c8e562d6a3c533271ff21 100644 --- a/lib/api/ci/runner.rb +++ b/lib/api/ci/runner.rb @@ -5,6 +5,8 @@ module Ci class Runner < Grape::API::Instance helpers ::API::Helpers::Runner + content_type :txt, 'text/plain' + resource :runners do desc 'Registers a new Runner' do success Entities::RunnerRegistrationDetails diff --git a/lib/api/go_proxy.rb b/lib/api/go_proxy.rb index c0207f9169c8327558adc81c6b287a9ed9599cdd..897b31cad488f2155ce70f23f3dacf35ad4d32d1 100755 --- a/lib/api/go_proxy.rb +++ b/lib/api/go_proxy.rb @@ -9,6 +9,8 @@ class GoProxy < Grape::API::Instance MODULE_VERSION_REQUIREMENTS = { module_version: MODULE_VERSION_REGEX }.freeze + content_type :txt, 'text/plain' + before { require_packages_enabled! } helpers do diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 81702f8f02a19f0a50479b004d7daf0ffed7ba37..abdf0fef8c0ec185452d5742cc1674be837c83bc 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -6,6 +6,8 @@ module API class Repositories < Grape::API::Instance include PaginationParams + content_type :txt, 'text/plain' + helpers ::API::Helpers::HeadersHelpers before { authorize! :download_code, user_project }