altinn-studio icon indicating copy to clipboard operation
altinn-studio copied to clipboard

Datamodelling: Testdata and converter have wrong array spesification

Open mijohansen opened this issue 2 years ago • 0 comments

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.

  1. Adding array restrictions minItems and maxItems 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.

  1. Problem is that some places there is added XSD-custom attributes to the type="array"-level and other places it connected to the items-level. This creates the need to keep track of both, which is really no needed as XSDs really not have a array-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

  1. open the ide
  2. navigate to one of the broken files and search for type="array"

Additional Information

No response

mijohansen avatar Oct 13 '22 15:10 mijohansen