Thanks for the help but this will not be very practical.
This would work, but I don't want to modify every swagger of every api that I publish on the gateway. And in almost every api modification i will have to modify my swagger file again.
I was able to resolve the problem by creating a custom assertion that basically do a replace in a string using a regex.
@Override public CustomAssertionStatus checkRequest(final CustomPolicyContext policyContext) { logger.log(Level.FINE, "StringReplaceServiceInvocation.checkRequest(...)"); try{ if (!(customAssertion instanceof StringReplaceCustomAssertion)) { logger.log(Level.SEVERE, String.format("customAssertion must be of type [{%s}], but it is of type [{%s}] instead", StringReplaceCustomAssertion.class.getSimpleName(), customAssertion.getClass().getSimpleName())); return CustomAssertionStatus.FAILED; } String input=(String)policyContext.getVariable("input"); String pattern=(String)policyContext.getVariable("pattern"); String replace=(String)policyContext.getVariable("replace"); String output=input.replaceAll(pattern,replace); policyContext.setVariable("output", output); }catch(Exception ex){ StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); logger.log(Level.SEVERE,"Error in assertion StringReplace: " + sw.toString()); return CustomAssertionStatus.FAILED; } return CustomAssertionStatus.NONE; }