Configuration
Configure your App in Ergonode
If the App requires configuration and defines configuration form in configuration_schema it has to appropriately handle the values.
It has to be able to validate and persist the configuration and also provide the configuration for reading.
To do so 2 endpoints implementation is necessary.
[GET] /configuration
The endpoint should return all so-far persisted schemas in update configuration steps in the form of an array of data - according to your schema.
For example for a simple configuration schema
{
"configuration_schema": [
{
"title": "Connection",
"type": "object",
"properties": {
"token": {
"type": "string",
"title": "API token",
"widget": "password",
"propertyOrder": 1
}
},
"required": [
"token"
]
},
{
"title": "Settings",
"type": "object",
"properties": {
"setting1": {
"type": "string",
"title": "setting 1",
"propertyOrder": 1
},
"setting2": {
"type": "string",
"title": "setting 2",
"propertyOrder": 1
}
},
"required": [
"text"
]
}
]
}
the expected response would be
[
{
"token": "secret API token"
},
{
"setting1": "user input text 1",
"setting2": "user input text 2"
}
]
[POST] /configuration
The endpoint accepts, validates, and persists in the configuration step.
payload
{
"index": 0,
"configuration": {
"text": "user input text"
}
}
All 2xx responses will be treated as success.
Error handling
The forms are validated against configuration schema but not all validation can be performed based on JSON schema.
I.e. API token can only be verified in the App.
To assign a custom error message to specific user form fields it is required to return an error response with code 422 and the payload
{
"title": "Form validation errors.",
"detail": "Token for API is not valid",
"violations": [
{
"propertyPath": "token",
"title": "Token for API is not valid",
"template": "Token for %parameter% is not valid",
"parameters": {
"%parameter%": "API"
}
}
]
}
All other error codes will be treated with a generic error message.
Last updated
Was this helpful?