Commit 29e6b5ce authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ) Committed by Mark Chao

Remove feature flag api_always_use_application_json [RUN ALL RSPEC] [RUN AS-IF-FOSS]

parent 0293d150
---
title: Remove feature flag api_always_use_application_json
merge_request: 56777
author:
type: removed
---
name: api_always_use_application_json
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/42229
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/270067
milestone: '13.6'
type: development
group: group::ecosystem
default_enabled: true
......@@ -776,7 +776,3 @@ some API endpoints also support `text/plain`.
In [GitLab 13.10 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/250342),
API endpoints do not support `text/plain` by default, unless it's explicitly documented.
This change is deployed behind the `:api_always_use_application_json` [feature flag](../user/feature_flags.md),
enabled by default. On GitLab self-managed instances, GitLab administrators can choose
to [disable it](../administration/feature_flags.md). **(FREE SELF)**
......@@ -130,32 +130,6 @@ module API
formatter :json, Gitlab::Json::GrapeFormatter
content_type :json, 'application/json'
# Remove the `text/plain+deprecated` with `api_always_use_application_json` feature flag
# 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.
# The `+deprecated` is added to distinguish content type
# as defined by `API::API` vs ex. `API::Repositories`
content_type :txt, 'text/plain+deprecated'
before do
# the feature flag workaround is only for `.txt`
api_format = env[Grape::Env::API_FORMAT]
next unless api_format == :txt
# get all defined content-types for the endpoint
api_endpoint = env[Grape::Env::API_ENDPOINT]
content_types = api_endpoint&.namespace_stackable_with_hash(:content_types).to_h
# Only overwrite `text/plain+deprecated`
if content_types[api_format] == 'text/plain+deprecated'
if Feature.enabled?(:api_always_use_application_json, default_enabled: :yaml)
content_type 'application/json'
else
content_type 'text/plain'
end
end
end
# Ensure the namespace is right, otherwise we might load Grape::API::Helpers
helpers ::API::Helpers
helpers ::API::Helpers::CommonHelpers
......
......@@ -170,20 +170,6 @@ RSpec.describe API::API do
expect(response.media_type).to eq('application/json')
expect(response.body).to include('{"id":')
end
context 'when api_always_use_application_json is disabled' do
before do
stub_feature_flags(api_always_use_application_json: false)
end
it 'returns text/plain' do
subject
expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq('text/plain')
expect(response.body).to include('#<API::Entities::User:')
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment