regurgitator is a lightweight, modular, extendable java framework that you configure to ‘regurgitate’ canned or clever responses to incoming requests; useful for quickly mocking or prototyping services without writing any code. simply configure, deploy and run.
start your reading here: regurgitator-all
read more about regurgitator in yml here: regurgitator-core-yml
a json-parameter creates a parameter, extracting its value from within a json document, using json-path:
json-parameter:
name: book-name
source: book-catalogue
json-path: $.catalogue.book.name
an xml-parameter creates a parameter, extracting its value from within an xml document, using xpath:
xml-parameter:
name: book-name
source: book-catalogue
xpath: /bk:catalogue/bk:book/bk:name
namespaces:
bk: http://books.com
a freemarker-builder aggregates parameter values together using a freemarker template.
freemarker-builder:
source: template-param
freemarker-builder:
file: classpath:/template.ftl
freemarker-builder:
value: This is a ${descriptive} day
a freemarker-builder can use the same value source properties as other steps, such as create-parameter
, getting its template text from a source parameter, a file or an explicit value.
a freemarker-builder builds from just the parameters
context by default. if the all-contexts
property is true, all context data is made available to the builder, with dashes replaced by underscores in context names, and the colon separating context and parameter names replaced with a period, e.g. request-metadata:method
becomes request_metadata.method
when referenced in the template.
freemarker-builder:
all-contexts: true
value: <response><payload>${response_payload.text}</payload><status-code>${response_metadata.status_code}</status-code><content-type>${response_metadata.content_type}</content-type></response>
a json-path-processor processes a parameter value, extracting a value from it using json path.
create-parameter:
name: book-name
source: book-catalogue
processor:
json-path-processor:
json-path: $.catalogue.book.name
an xpath-processor processes a parameter value, extracting a value from it using xpath.
create-parameter:
name: book-name
source: book-catalogue
processor:
xpath-processor:
xpath: /cat:atalogue/bk:book/@name
namespaces: cat=http://catalogues.com,bk=http://books.com
namespaces for an xpath-processor can also be declared as an object property of the processor:
create-parameter:
name: book-name
source: book-catalogue
processor:
xpath-processor:
xpath: /cat:atalogue/bk:book/@name
namespaces:
cat: http://catalogues.com
bk: http://books.com
a freemarker-processor processes a parameter value, formatting the value using a freemarker template.
create-response:
source: unformatted-response
processor:
freemarker-processor:
file: classpath:/template.ftl
create-response:
source: unformatted-response
processor:
freemarker-processor:
value: The response was: ${value}
the parameter value is made available to the template as simply value
. the template text can be specified in a value
property or drawn in from a file.
a json-schema-validator is a value-processor
that validates a parameter value against a json schema file.
create-response:
source: response
processor:
xml-schema-validator:
file: classpath:/response_schema.json
validating a parameter value can be useful in ensuring that your configured logic and processing always returns valid responses. if the value fails validation, an exception is thrown; if it passes, the value is passed through unchanged.
an xml-schema-validator is a value-processor
that validates a parameter value against an xml schema file.
create-response:
source: response
processor:
xml-schema-validator:
file: classpath:/response_schema.xsd
validating a parameter value can be useful in ensuring that your configured logic and processing always returns valid responses. if the value fails validation, an exception is thrown; if it passes, the value is passed through unchanged.
a contains-json-path is a condition-behaviour
that checks whether a parameter’s contents contains a sub-value that can be extracted using an json-path expression. if a sub-value can be extracted from the starting value using the json-path expression provided then the condition passes.
...
conditions:
- source: parameters:json
contains-json-path: $.catalog.book.name
...
...
conditions:
- source: parameters:json
value: $.catalog.book.name
behaviour: contains-json-path
...
the examples above show both ways in which the contains-json-path condition-behaviour
can be used, either in the short form of "behaviour-name" : "value"
or with separate value
and behaviour
attributes.
a contains-xpath is a condition-behaviour
that checks whether a parameter’s contents contains a sub-value that can be extracted using an xpath expression. if a sub-value can be extracted from the starting value using the xpath expression provided then the condition passes.
...
conditions:
- source: parameters:xml
contains-xpath: /catalog/book/@name
...
...
conditions:
- source: parameters:xml
value: /catalog/book/@name
behaviour: contains-xpath
...
...
conditions:
- source: parameters:xml
value: /catalog/book/@name
behaviour:
contains-xpath:
namespaces: cat=http://catalog.com,book=http://book.com
...
...
conditions:
- source: parameters:xml
value: /catalog/book/@name
behaviour:
contains-xpath:
namespaces:
cat: http://catalog.com
book: http://book.com
...
the examples above shows 3 ways in which the contains-xpath condition-behaviour
can be used: in the short form of "behaviour-name" : "value"
; with separate value
and behaviour
attributes; or with a child object. When using a child object, you can either specify namespaces for the xpath expression using a namespaces
attribute, or a namespaces
object.
a meets-json-schema is a condition-behaviour
that checks whether a parameters’ content passes validation against a json schema.
...
conditions:
- source: parameters:json
meets-json-schema: classpath:/schema.json
...
...
conditions:
- source: parameters:json
value: classpath:/schema.json
behaviour: meets-json-schema
...
the examples above show both ways in which the meets-json-schema condition-behaviour
can be used, either in the short form of "behaviour-name" : "value"
or with separate value
and behaviour
attributes.
a meets-xml-schema is a condition-behaviour
that checks whether a parameters’ content passes validation against an xml schema.
...
conditions:
- source: parameters:xml
meets-xml-schema: classpath:/schema.xsd
...
...
conditions:
- source: parameters:xml
value: classpath:/schema.xsd
behaviour: meets-xml-schema
...
the examples above show both ways in which the meets-xml-schema condition-behaviour
can be used, either in the short form of "behaviour-name" : "value"
or with separate value
and behaviour
attributes.