opa
opa copied to clipboard
Make http.send accept any json variant as application/json
What is the underlying problem you're trying to solve?
Our SCIM server returns application/scim+json
as a Content-Type
header. We need to enable force_json_decode
to get the raw_body
parsed into body
.
Describe the ideal solution
It would be nice if opa would understand that application/variant+json
is just a variant of application/json
for any variant
of json so it would not be necessary to add force_json_decode
to the request body.
Describe a "Good Enough" solution
users_request := {
"url": "https://scimserver/Users",
"method": "GET",
"headers": {
"x-api-key": "secret",
"accept": "application/scim+json"
}
}
... would return a valid decoded body in the result.
Sounds like a reasonable improvement to me. If you'd like to submit a PR, that'd be neat 🙂
"For more information, please re-read." -- I've removed my comment re force_json_decode, you're already aware. 😅
💭 Right now, application/json is json-decoded, and application/yaml + application/x-yaml are yaml-decoded. So if we go with
users_request := {
"url": "https://scimserver/Users",
"method": "GET",
"headers": {
"x-api-key": "secret",
"accept": "application/scim+json"
}
}
would this mean it should do JSON? How would I declare that a certain extra header value means that it should be treated as YAML?
No, my suggestion was not to use the "accept" header, that's just to show a correct SCIM request body. My suggestion is to be lenient about the returned application/<anything+>json
Content-Type.
Ah! Thanks for clarifying. Yeah, that makes this a bit simpler.
This method handles the response processing which would need to be updated I think. Feel free to submit a PR if you'd like. Thanks.