altinn-studio
altinn-studio copied to clipboard
Datamodelling: Testdata and converter have wrong array spesification
Description of the bug
In several of the test schemas there is error in the logic around arrays. To be able to reuse thoose schemas for the frontend we have disabled several in our tests.
src/studio/src/designer/DataModeling.Tests/_TestData/Model/JsonSchema/General/ComplexSchema.json
src/studio/src/designer/DataModeling.Tests/_TestData/Model/JsonSchema/General/NestedArrays.json
src/studio/src/designer/DataModeling.Tests/_TestData/Model/JsonSchema/General/NestedWithArraySequence.json
src/studio/src/designer/DataModeling.Tests/_TestData/Model/JsonSchema/General/NillableAttribute.json
src/studio/src/designer/DataModeling.Tests/_TestData/Model/JsonSchema/Seres/SeresArray.json
src/studio/src/designer/DataModeling.Tests/_TestData/Model/JsonSchema/Seres/SeresNillable.json
There is two main issues in these schemas, one which must be categorized as a bug, and one which increases complexity that doesn't need to be in our solution.
- Adding array restrictions
minItems
andmaxItems
to the subschema(items
) in the array. For instance like this:
{
"properties": {
"e1": {
"@xsdType": "string",
"type": "string"
},
"e2": {
"@xsdType": "string",
"items": {
"maxItems": 100,
"type": "string"
},
"minItems": 0,
"type": "array"
}
},
"required": ["e1"]
}
Where type="string"
never can have the maxItems
restriction as its a string and not an array.
- Problem is that some places there is added XSD-custom attributes to the
type="array"
-level and other places it connected to theitems
-level. This creates the need to keep track of both, which is really no needed as XSDs really not have aarray
-level.
The correct way should be:
{
"type": "array",
"minItems": 0,
"maxItems": 100,
"items": {
"type": "string",
"@xsdType": "string"
}
}
Where you should place all logic needed to convert to a correct xsd ion the items
-level.
Steps To Reproduce
- open the ide
- navigate to one of the broken files and search for
type="array"
Additional Information
No response