I have…
- [x] Read the following guideline: https://docs.squidex.io/01-getting-started/installation/troubleshooting-and-support. I understand that my support request might get deleted if I do not follow the guideline.
I’m submitting a…
- [ ] Regression (a behavior that stopped working in a new release)
- [x] Bug report
- [ ] Performance issue
- [ ] Documentation issue or request
Current behavior
When having an empty invariant nested field on a squidex, the api will return an empty object. When having the following attribute
[JsonConverter(typeof(InvariantConverter))]
the code will break on the check to see if it’s actually an IV field.
Example of the field in squidex
{
"name": "colors",
"properties": {
"isRequired": false,
"isRequiredOnPublish": false,
"isHalfWidth": false,
"fieldType": "Array",
"minItems": 0,
"maxItems": 3,
"label": "Colors",
"hints": "Themed Colours. Will alternate between"
},
"isLocked": false,
"isHidden": false,
"isDisabled": false,
"partitioning": "invariant",
"nested": [
{
"name": "color",
"properties": {
"isRequired": true,
"isRequiredOnPublish": false,
"isHalfWidth": true,
"fieldType": "String",
"editor": "Dropdown",
"inlineEditable": false,
"isUnique": false,
"defaultValue": "Primary",
"allowedValues": [
"Primary",
"Secondary",
"Tertiary",
"Quaternary"
],
"contentType": "Unspecified",
"label": "Color",
"hints": "The color of the card",
"placeholder": ""
},
"isLocked": false,
"isHidden": false,
"isDisabled": false
}
]
},
example response
{
"id": "b78c3e87-498a-4aff-9cd9-4b3f88bd7b18",
"createdBy": "...",
"lastModifiedBy": "...",
"data": {
"fullWidth": {
"iv": true
},
"centerText": {
"iv": true
},
"colorGradient": {
"iv": false
},
"colors": {},
"title": {
"nl": "..."
},
"description": {
"nl": "..."
},
"cards": {
"iv": [
"552030..9f2",
"77aa67..e4",
"3b9520..ab"
]
},
"deletedDate": {
"iv": null
},
"publishedDate": {
"iv": "2021-03-30T13:02:46Z"
}
},
"created": "2021-03-30T13:02:46Z",
"lastModified": "2021-05-01T22:48:49Z",
"status": "Published",
"statusColor": "#4bb958",
"schemaName": "cardsection",
"schemaDisplayName": "Cards",
"version": 3,
"_links": {
"self": {
"href": "...",
"method": "GET"
},
"previous": {
"href": "...",
"method": "GET"
},
"draft/create": {
"href": "...",
"method": "POST"
},
"delete": {
"href": "...",
"method": "DELETE"
}
}
}
As you can see the "colors": {},
is just an empty object.
Expected behavior
I think it would be beneficial if squidex would send the following object for invariant nested fields
{
...
"colors":{
"iv" : []
}
}
On first glimpse this would allow the ClientLibrary converter not fall over the empty object & insert an ‘empty’ collection into the correct field.
Alternatively an null could also be set, for a null value for the collection instead of an empty collection.
Minimal reproduction of the problem
- Create an scheme with an nested object like the one included
- Create content from said scheme, but don´t add any nested objects
- Create a C# model to work with the client library, and use the invariant converter
- Request the data
Environment
- [ ] Self hosted with docker
- [ ] Self hosted with IIS
- [ ] Self hosted with other version
- [x] Cloud version
Browser:
- [ ] Chrome (desktop)
- [ ] Chrome (Android)
- [ ] Chrome (iOS)
- [x] Vivaldi (Chromium)
- [ ] Firefox
- [ ] Safari (desktop)
- [ ] Safari (iOS)
- [ ] IE
- [ ] Edge