Optum / mockiato

A web-based platform for API virtualization
Apache License 2.0
24 stars 9 forks source link

Random Responses #434

Closed johnlegeyt closed 5 years ago

johnlegeyt commented 5 years ago

Random data can now be inserted into responses via templating tags in the format:

{{random:method:arg1,val1:arg2,val2:arg3...}}

Where method is a method from the Chance library (https://chancejs.com/ for a full list), and arg1/val1, arg2/val2 etc are name/value pairs of arguments to those methods.

E.g. {{random:name:nationality,it:middle_initial,true}} would be replaced with a random, italian name with a middle initial (like Gianni V. Venturi).

The seed for the random generation is created by hashing the request body, the request queries, and the request path to ensure that the exact same request will always generate the exact same response, but different requests will generate different, randomized responses.

When updating a service, a check to see if the response body contains any random data tags is cached in the RRPair document in order to keep the impact of this new feature on performance minimal when it is not being used.

Closes #346