wso2 / ballerina-vscode

To keep Ballerina VSCode plugin related issues, discussions, etc.
Apache License 2.0
42 stars 20 forks source link

Improve the union type field support in Types Diagram #270

Open aneeshafedo opened 1 year ago

aneeshafedo commented 1 year ago

Description: $subject

Describe your problem(s) In the current model type of a union type field has been represented as a pipe separated string. Current json object for union types

{
          "name": "totalReservations",
          "type": "aneesha/reservation_api:0.1.0:ConfirmedReservation[]|aneesha/reservation_api:0.1.0:Reservation[]",
          "optional": false,
          "nillable": false,
          "defaultValue": "",
          "associations": [
            {
              "associate": "aneesha/reservation_api:0.1.0:ConfirmedReservation",
              "cardinality": { "self": "1-1", "associate": "1-m" }
            },
            {
              "associate": "aneesha/reservation_api:0.1.0:Reservation",
              "cardinality": { "self": "1-1", "associate": "1-m" }
            }
          ],
          ...
        },

Describe your solution(s)

Update type string attribute to types, string[] attribute.

Proposed object

{
          "name": "totalReservations",
          "type": ["aneesha/reservation_api:0.1.0:ConfirmedReservation[]", "aneesha/reservation_api:0.1.0:Reservation[]],
          "optional": false,
          "nillable": false,
          "defaultValue": "",
          "associations": [
            {
              "associate": "aneesha/reservation_api:0.1.0:ConfirmedReservation",
              "cardinality": { "self": "1-1", "associate": "1-m" }
            },
            {
              "associate": "aneesha/reservation_api:0.1.0:Reservation",
              "cardinality": { "self": "1-1", "associate": "1-m" }
            }
          ],
          ...
        },

@NipunaRanasinghe WDYT ?

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):

NipunaRanasinghe commented 1 year ago

@aneeshafedo IMO we better think of a new design considering the intersection types as well. Therefore it will be better if we can find a way to distinguish union types and the intersection types in our BE model to be future proof.

aneeshafedo commented 1 year ago

@aneeshafedo IMO we better think of a new design considering the intersection types as well. Therefore it will be better if we can find a way to distinguish union types and the intersection types in our BE model to be future proof.

Ack. Will come up with a new design