More often than not, API simulations require HTTP responses to change between requests for the same simlet. Response templating is the solution for building dynamic HTTP responses.
Simula is the API Simulator’s text template engine.
The template engine takes a template and combines it with data to produce the HTTP response.
A template consists of fragments. Some fragments don’t change and others can produce variable content.
Placeholders are a type of fragments that can produce variable content. A placeholder gets resolved to an actual value as part of rendering the template. By default,
} enclose placeholders.
Another kind of fragments that can produce variable content is the scripting fragments, or scriptlets. Scriptlets are code. The template engine executes the code upon rendering the template, which may produce output. By default, scriptlets are delimited by
Here is how to define that a response is rendered from a Simula template:
The same configuration elements described in Response Stubbing can be configured with a Simula template:
HTTP Protocol Version
Text Body Content, or
Binary Body Content, with
Base64-Encoded Body Content, or
Binary Body Content From a File
It is just that they can be dynamic, as needed.
The next pages will cover the various aspects of configuring a template.
We would love to hear your feedback! Shoot us an email to [feedback at APISimulator.com] about anything that is on your mind.
Happy API Simulating!