-
Notifications
You must be signed in to change notification settings - Fork 0
Built in suppliers
This page contains the bundled Suppliers implementations we offer.
Each supplier has only one purpose: supplies an output value. Even though they don't have parameters runtime, we still need to tell them what they need to supply when they are called. This means that we must use some input parameters most likely to control this.
Each supplier has a version when it was added to the app, a class implementing them, a name they are registered with, an output type, a parameter list defining how they can be configured, a description stating what they are supposed to do, and we will show an example configuration as well.
Name: converting
Class: ConvertingSupplier
Since version: 1.2.0
Output type: Object
Parameters
Name | Type | Description |
---|---|---|
stringSource |
Supplier < String > |
The supplier of the raw String data we will use as input. |
converter |
Function < String , Object > |
The function that will convert the string data. |
Description
This supplier allows us to supply more complex objects with the help of a function that can covert strings into other types. As long as we have the right functions this can be a very powerful supplier.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[*]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "address"
value: # this is the node defining the converting supplier
name: "converting"
stringSource: # this supplier would return a lowercase value
name: "staticString"
value: "missing"
converter: # then this function will turn it into Capital
name: "changeCase"
to: "CAPITALIZED"
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"address": "Missing"
},
{
"id": 2,
"name": "Jane Doe",
"address": "Missing"
}
]
}
In this example the capitalized value of "Missing" was added thanks to the converting supplier.
Name: file
Class: FileContentSupplier
Since version: 1.2.0
Output type: String
Parameters
Name | Type | Description |
---|---|---|
path |
String |
The path of the file we want to use as input. |
charset |
Charset |
The charset used for reading the contents of the file. Defaults to UTF-8. |
Description
This supplier returns the contents of a file as text.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules: # this is where our rule is defined
- name: "validate"
path: "$"
params:
schema: # this is where our schema validation node is
name: "jsonSchema"
source: # using the input JSON file as the schema to validate itself
name: "file"
path: "src/main/resources/examples/json/validation-input.json"
onFailure:
# we will stop the processing but save partial results
transformation: "SKIP_REST"
# add violation errors to the document itself
violation: "COMMENT_JSON"
On this input
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"$schema": {
"type": "string",
"const": "http://json-schema.org/draft-07/schema"
},
"properties": {
"type": "object",
"properties": {
"$schema": {
"type": "object"
},
"properties": {
"type": "object"
}
},
"required": [
"$schema",
"properties"
],
"additionalProperties": false
}
},
"additionalProperties": false
}
Produces this output
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"$schema": {
"type": "string",
"const": "http://json-schema.org/draft-07/schema"
},
"properties": {
"type": "object",
"properties": {
"$schema": {
"type": "object"
},
"properties": {
"type": "object"
}
},
"required": [
"$schema",
"properties"
],
"additionalProperties": false
}
},
"additionalProperties": false,
"$_yippee-schema-violation": [
{
"message": "$.additionalProperties: is not defined in the schema and the schema does not allow additional properties",
"path": "$"
}
]
}
In this example our file supplier provided the contents of the schema.
Name: httpResource
Class: HttpResourceContentSupplier
Since version: 1.2.0
Output type: String
Parameters
Name | Type | Description |
---|---|---|
uri |
String |
The URI we want to send the request to. |
httpMethod |
HttpMethod |
The HTTP request method we want to use. Defaults to GET. |
httpHeaders |
Map < String , String > |
HTTP headers we want to send with our request. |
charset |
Charset |
The charset used for reading the contents of the response. Defaults to UTF-8. |
Description
This supplier returns the contents of an HTTP resource as text.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules: # this is where our rule is defined
- name: "add"
path: "$"
params:
key: # we will add the content under the example node
name: "staticString"
value: "example"
value:
name: "converting"
stringSource:
name: "httpResource" # this is the supplier downloading the content
uri: "https://raw.githubusercontent.com/nagyesta/yippee-ki-json/main/src/test/resources/json/example.json"
httpMethod: "GET"
converter: # this converter parses our downloaded response
name: "jsonParse"
On this input
{
"uri": "example.json",
"method": "GET"
}
Produces this output
{
"uri": "example.json",
"method": "GET",
"example": {
"accounts": [
{
"id": 1,
"name": "John Doe",
"email": "[email protected]"
},
{
"id": 2,
"name": "Peter Parker",
"email": "[email protected]"
},
{
"id": 3,
"name": "Jane Doe",
"email": "[email protected]"
},
{
"id": 4,
"name": "John Smith",
"email": "[email protected]"
}
]
}
}
In this example we have downloaded a file and saved it's contents.
Name: jsonSchema
Class: JsonSchemaSupplier
Since version: 1.2.0
Output type: JsonSchema
Parameters
Name | Type | Description |
---|---|---|
source |
Supplier < String > |
The supplier of the String of the JSON Schema which we will use as input. |
Description
This supplier returns a JSON schema from the string input provided in the configuration.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules: # this is where our rule is defined
- name: "validate"
path: "$"
params:
schema: # this is where our schema validation node is
name: "jsonSchema"
source: # using the input JSON file as the schema to validate itself
name: "file"
path: "src/main/resources/examples/json/validation-input.json"
onFailure:
# we will stop the processing but save partial results
transformation: "SKIP_REST"
# add violation errors to the document itself
violation: "COMMENT_JSON"
On this input
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"$schema": {
"type": "string",
"const": "http://json-schema.org/draft-07/schema"
},
"properties": {
"type": "object",
"properties": {
"$schema": {
"type": "object"
},
"properties": {
"type": "object"
}
},
"required": [
"$schema",
"properties"
],
"additionalProperties": false
}
},
"additionalProperties": false
}
Produces this output
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"$schema": {
"type": "string",
"const": "http://json-schema.org/draft-07/schema"
},
"properties": {
"type": "object",
"properties": {
"$schema": {
"type": "object"
},
"properties": {
"type": "object"
}
},
"required": [
"$schema",
"properties"
],
"additionalProperties": false
}
},
"additionalProperties": false,
"$_yippee-schema-violation": [
{
"message": "$.additionalProperties: is not defined in the schema and the schema does not allow additional properties",
"path": "$"
}
]
}
In this example we have provided a local file (which happens to be the input file) as schema.
Name: schemaStore
Class: SchemaStoreSchemaContentSupplier
Since version: 1.2.0
Output type: String
Parameters
Name | Type | Description |
---|---|---|
schemaName |
String |
The name of the JSON schema as found in the SchemaStore.org catalog. |
Description
This supplier returns a JSON schema downloaded from SchemaStore.org .
Example configuration
Applying this configuration
actions:
- name: "demo"
rules: # this is where our rule is defined
- name: "validate"
path: "$"
params:
schema: # this is where our schema validation node is
name: "jsonSchema"
source: # this is where our schema download node is
name: "schemaStore"
schemaName: "Yippee-Ki-JSON configuration YML"
onFailure:
# we will continue despite the failure
transformation: "CONTINUE"
# add violation errors to the document itself
violation: "COMMENT_JSON"
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
],
"$_yippee-schema-violation": [
{
"message": "$.actions: is missing but it is required",
"path": "$"
},
{
"message": "$.accounts: is not defined in the schema and the schema does not allow additional properties",
"path": "$"
}
]
}
In this example we have validated a clearly incompatible input against our own YML schema.
Name: staticJson
Class: StaticJsonSupplier
Since version: 1.1.0
Output type: Object
Parameters
Name | Type | Description |
---|---|---|
value |
String |
The static JSON value we want to supply every time our supplier is called. |
Description
This supplier allows us to supply more complex objects using a JSON representation in our configuration.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[*]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "address"
value: # this is the node defining the second supplier
name: "staticJson"
value: '{"home":"123 Main street, SomeCity"}'
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"address": {
"home": "123 Main street, SomeCity"
}
},
{
"id": 2,
"name": "Jane Doe",
"address": {
"home": "123 Main street, SomeCity"
}
}
]
}
In this example the second supplier will return an Object containing the "home" key when called.
Name: staticString
Class: StaticStringSupplier
Since version: 1.0.0
Output type: String
Parameters
Name | Type | Description |
---|---|---|
value |
String |
The static value that must be returned each time the supplier is called. |
Description
This supplier is essentially a fancy way of using a String literal. Whatever value you add to the config, it will be returned as is.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[*]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "address"
value: # this is the node defining the second supplier
name: "staticJson"
value: '{"home":"123 Main street, SomeCity"}'
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"address": {
"home": "123 Main street, SomeCity"
}
},
{
"id": 2,
"name": "Jane Doe",
"address": {
"home": "123 Main street, SomeCity"
}
}
]
}
This example will return "address" whenever the first supplier is called.
Name: staticInteger
Class: StaticIntegerSupplier
Since version: 1.4.0
Output type: BigInteger
Parameters
Name | Type | Description |
---|---|---|
value |
BigInteger |
The static value that must be returned each time the supplier is called. |
Description
This supplier is essentially a fancy way of using a BigInteger literal. The literal value entered in the config will be converted from String.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[*]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "roleId"
value: # this is the node defining the second supplier
name: "staticInteger"
value: 20
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"roleId": 20
},
{
"id": 2,
"name": "Jane Doe",
"roleId": 20
}
]
}
This example will return 20 whenever the second supplier is called.
Name: staticDecimal
Class: StaticDecimalSupplier
Since version: 1.4.0
Output type: BigDecimal
Parameters
Name | Type | Description |
---|---|---|
value |
BigDecimal |
The static value that must be returned each time the supplier is called. |
Description
This supplier is essentially a fancy way of using a BigDecimal literal. The literal value entered in the config will be converted from String.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[0]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "rating"
value: # this is the node defining the second supplier
name: "staticDecimal"
value: 4.5
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"rating": 4.5
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
This example will return 4.5 when the second supplier is called.
Name: staticBoolean
Class: StaticBooleanSupplier
Since version: 1.4.0
Output type: Boolean
Parameters
Name | Type | Description |
---|---|---|
value |
Boolean |
The static value that must be returned each time the supplier is called. |
Description
This supplier is essentially a fancy way of using a Boolean literal. The literal value entered in the config will be converted from String.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[1]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "signInAllowed"
value: # this is the node defining the second supplier
name: "staticBoolean"
value: false
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe",
"signInAllowed": false
}
]
}
This example will return false when the second supplier is called.
Name: epochMillisRelativeDate
Class: EpocMillisRelativeDateSupplier
Since version: 1.4.0
Output type: BigInteger
Parameters
Name | Type | Description |
---|---|---|
amount |
Integer |
The amount of time units we need to add to the current date time. |
unit |
ChronoUnit |
The time unit we want to use to interpret the amount. |
relativeTo |
BigInteger |
The value we want to be relative to (in case it is not the current time). |
Description
This supplier returns a datetime value in the epoch millis format as integer. The value will be calculated relative from a predefined time (or the current time if not defined) using the configuration values provided.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[0]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "registeredSince"
value: # this is the node defining the second supplier
name: "epochMillisRelativeDate"
amount: 1
unit: "HOURS"
relativeTo: 0
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"registeredSince": 3600000
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
This example will return 3 600 000 when the second supplier is called.
Name: relativeStringDate
Class: RelativeStringDateSupplier
Since version: 1.4.0
Output type: String
Parameters
Name | Type | Description |
---|---|---|
formatter |
String |
The format String we need to use for date time parsing. See |
amount |
Integer |
The amount of time units we need to add to the current date time. |
unit |
ChronoUnit |
The time unit we want to use to interpret the amount. |
relativeTo |
String |
The value we want to be relative to (in case it is not the current time). |
Description
This supplier returns a datetime value in the String formatted way using the format provided. The value will be calculated relative from a predefined time (or the current time if not defined) using the configuration values provided.
Example configuration
Applying this configuration
actions:
- name: "demo"
rules:
- name: "add"
path: "$.accounts[0]"
params:
key: # this is the node defining the first supplier
name: "staticString"
value: "updatedOn"
value: # this is the node defining the second supplier
name: "relativeStringDate"
formatter: "yyyy-MM-dd"
amount: 1
unit: "DAYS"
relativeTo: "2020-01-01"
On this input
{
"accounts": [
{
"id": 1,
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
Produces this output
{
"accounts": [
{
"id": 1,
"name": "John Doe",
"updatedOn": "2020-01-02"
},
{
"id": 2,
"name": "Jane Doe"
}
]
}
This example will return '2020-01-02' when the second supplier is called.