Hi there,
I am looking at the new schemas json trying to understand how to create it and what are they meant at. Unfortunatelly I cannot find infos about that on the documentation (nothing more than a few examples).
Specifically:
Which is the format of the JSON for the “input schema” which infos can I insert? Which types of data?
The same for the output schema, where I am guessing that the schema is for the download queue button.
i will risk it and say it is there just as a reference for any developers that will be using those, so they know the schema they will need to follow when adding or retrieving transactions…
I was looking into this today and this was one of the top search results but doesn’t seem to explain it in any detail so here is what I found myself.
So, on a queue item you have the following properties:
SpecificData (populated when the queue item is created)
OutputData (populated when the queue item is completed)
AnalyticsData (populated when the queue item is completed)
The three JSON schemas you can upload in orchestrator correspond to these properties and basically allow an automatic validation of the data in those fields at various stages.
For example, if you have a JSON Schema for the Specific Data when you try to add an item to a queue the input data will be checked to see if it matches the schema, if it does not then the queue item will not be added and a business exception will occur.
The other two schemas are validated when the queue item status is set to ‘Successful’, if either validation fails then the queue item will fail with a business exception.
Hopefully you can see scenarios where this is useful in validating data. Here are some further reading which I think help explain it further.
As a test, I created a similar schema and uploaded it to a test queue under Specific Data JSON Schema. Orchestrator accepted it.
My schema:
{
"title": "Test",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
}
}
Next, I went into Studio and added an Add Queue Item activity. I set ItemInformation as shown in the screenshot.
When I run the project, an item is always added to the queue, despite the JSON schema not having Name or Show properties.
So the behaviour makes sense. I’ll try to explain by describing what your schema demands.
a firstName (optional) field of string type,
a lastName (optional) field of string type,
an age field (optional) of integer type, if filled has a minimum value of 0
The schema doesn’t stop extra fields being present so if we check against these rules your JSON input would validate against the schema as all the fields specified are missing, since they are all optional this is fine.
Now I’m no expert on JSON schemas as I work more frequently with XML but I think you want to look at adding something like this to your file
“required”: ["firstName ", "lastName ", "age "],
You would then need to provide a value for those 3 fields meaning your input would now fail the validation.
I think it bears pointing out that the schema validation only occurs on certain activities as far as I know. Changing the SpecificData dictionary directly in a workflow probably won’t trigger a validation check.
I didn’t really connect the dots until your answer that this is the JSON Schema defined here: https://json-schema.org/. This is my first real encounter with it beyond as a consumer.
Adding a $schema property to my JSON gave me autocomplete in VS Code. Adding required as you suggested made Add Queue Item throw an error in Studio for the ItemInformation screenshotted in my previous post.
{
"$schema": "http://json-schema.org/draft/2020-12/schema",
"title": "Test",
"type": "object",
"properties": {
"firstName": {
"type": "string",
"description": "The person's first name."
},
"lastName": {
"type": "string",
"description": "The person's last name."
},
"age": {
"description": "Age in years which must be equal to or greater than zero.",
"type": "integer",
"minimum": 0
}
},
"required": ["firstName", "lastName", "age"]
}
Sorry for addressing you as “anyone” in my previous post, by the way…I had edited the opening before posting, and by that time I forgot I’d started it as a reply.