diff --git a/changelog/unreleased/kong/feat-api-yaml-media-type.yml b/changelog/unreleased/kong/feat-api-yaml-media-type.yml new file mode 100644 index 000000000000..44c07afc3aa3 --- /dev/null +++ b/changelog/unreleased/kong/feat-api-yaml-media-type.yml @@ -0,0 +1,4 @@ +message: | + **Admin API**: Added support for official YAML media-type (application/yaml) to /config endpoint. +type: feature +scope: Admin API diff --git a/kong/api/api_helpers.lua b/kong/api/api_helpers.lua index 69e9822a8ede..62d51a859f91 100644 --- a/kong/api/api_helpers.lua +++ b/kong/api/api_helpers.lua @@ -260,7 +260,9 @@ function _M.before_filter(self) elseif sub(content_type, 1, 16) == "application/json" or sub(content_type, 1, 19) == "multipart/form-data" or sub(content_type, 1, 33) == "application/x-www-form-urlencoded" - or (ACCEPTS_YAML[self.route_name] and sub(content_type, 1, 9) == "text/yaml") + or (ACCEPTS_YAML[self.route_name] and + (sub(content_type, 1, 16) == "application/yaml" or + sub(content_type, 1, 9) == "text/yaml")) then return end diff --git a/spec/02-integration/04-admin_api/15-off_spec.lua b/spec/02-integration/04-admin_api/15-off_spec.lua index 6bf5324a8273..cfc6102ed516 100644 --- a/spec/02-integration/04-admin_api/15-off_spec.lua +++ b/spec/02-integration/04-admin_api/15-off_spec.lua @@ -247,7 +247,7 @@ describe("Admin API #off", function() - username: "bobby_in_yaml_body" ]]), headers = { - ["Content-Type"] = "text/yaml" + ["Content-Type"] = "application/yaml" }, }) @@ -3290,7 +3290,7 @@ describe("Admin API #off worker_consistency=eventual", function() - name: prometheus ]]), headers = { - ["Content-Type"] = "text/yaml" + ["Content-Type"] = "application/yaml" }, }) assert.response(res).has.status(201) @@ -3320,7 +3320,7 @@ describe("Admin API #off worker_consistency=eventual", function() - name: prometheus ]]), headers = { - ["Content-Type"] = "text/yaml" + ["Content-Type"] = "application/yaml" }, }) assert.response(res).has.status(201)