What is API Greasing? API greasing is a technique used to introduce controlled randomness in API responses or requests, ensuring that clients can handle unexpected variations in data structures. This helps improve system resilience and robustness.
In Membrane, you can add the grease
element to requests or responses to grease specific types of data. For example, using jsonGrease
to add noise to a JSON request. By setting the ratio to 10%, approximately 10 out of every 100 requests will be greased. In this example we set the ratio to 1.0 (default), this will force every request to be greased.
The following configuration applies JSON greasing to API responses.
<api port="2000">
<response>
<greaser>
<greaseJson ratio="1.0" shuffleFields="true" additionalProperties="true" />
</greaser>
</response>
<return />
</api>
0.1
for 10%).true
, JSON fields are reordered.greaseJson | Example |