We have a use case whereby we have optional query parameters in our API. For example, for one of our GET ‘list’ endpoints we’d like a query parameter named ‘skip’ that allows us to paginate through large datasets. We have something like the below in our request transformer:
add:
body:
- ‘skip:$(query_params[“skip”])’
However, from what I can see reading the documentation (Request Transformer plugin | Kong Docs) and looking online, it looks like there’s no way to conditionally add the optional query parameter to the request body (i.e. to maintain that optional notion) - have I got that right? As things stand, if ‘skip’ is not provided, it is still added to the request body but as an empty string (’’). This therefore means we have to add server-side logic to each back-end service that could receive such an optional query parameter to cater for the fact they could be empty (which is not ideal) - rather than the transformer simply not adding them if they’re not needed.
Any ideas if what I’m after is possible / any other workarounds?