krakend / krakend-ce

KrakenD Community Edition: High-performance, stateless, declarative, API Gateway written in Go.
https://www.krakend.io
Apache License 2.0
1.86k stars 443 forks source link

deny object key in response #867

Closed basaran closed 3 months ago

basaran commented 3 months ago

Environment info:

Version: 2.6.0 Linux 6.7.7-1-MANJARO x86_64

Describe what are you trying to do: API I'm testing with returns some JSON keys with dots in them. For instance:

{
    "@odata.context": "https://localhost/whatever",
}

I am trying to deny it in the response.

          "deny": [
            "@odata.context"
           ]

But it doesn't work. I did confirm though, I can rename this field. Is there a special syntax I need to use to escape the dot or the at symbol when using deny?

          "mapping": {
            "@odata.context": "heman"
          }

Renaming works fine.

alombarte commented 3 months ago

Hi @basaran, the deny, allow, or even the flatmap functionality reserves the dot to access nested objects (there are more components like this). There is no special syntax for working with literals containing dots, so this functionality is not supported in the community edition.

On the other hand, the mapping attribute does not support nested functionality, which is why you can work with literals with a dot. You could implement the logic using allow instead, or create an intermediate endpoint

basaran commented 3 months ago

thank you for the clarifications. Arigato.