Skip to content

Commit bc98bc5

Browse files
authored
fix: handle array of objects properly (#25)
1 parent 281eccb commit bc98bc5

File tree

6 files changed

+1028
-11
lines changed

6 files changed

+1028
-11
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
{
2+
"type": "object",
3+
"description": "This section allows the selection of the ticketing options for all sales of the order.",
4+
"properties": {
5+
"availableTicketingOptions": {
6+
"description": "List of ticketing options of the order.",
7+
"type": "array",
8+
"items": {
9+
"$ref": "../TicketingOptionInfo/TicketingOptionInfo.v1-0.yaml"
10+
}
11+
},
12+
"commonTicketingOptions": {
13+
"type": "array",
14+
"description": "Common ticketing options to all order items.",
15+
"items": {
16+
"type": "string"
17+
}
18+
},
19+
"ticketingOptionChoice": {
20+
"type": "array",
21+
"description": "Ticketing option selection per order item.",
22+
"items": {
23+
"type": "object",
24+
"properties": {
25+
"state": {
26+
"description": "The status that addresses if a specific ticket option is active or not. The status active is used before ticketing or before exchange confirmation. After ticketing, the status changes in completed. This allows to store ticketing options already used at ticketing time and to clean up all non selected options after ticketing or exchanged confirmation.",
27+
"type": "string",
28+
"default": "ACTIVE",
29+
"enum": [
30+
"COMPLETED",
31+
"ACTIVE"
32+
]
33+
},
34+
"orderItemBreakdown": {
35+
"description": "Structure that contains ticketing options per order item.",
36+
"type": "array",
37+
"items": {
38+
"type": "object",
39+
"properties": {
40+
"orderItemId": {
41+
"type": "string",
42+
"format": "uuid"
43+
},
44+
"options": {
45+
"description": "Available ticketing options for a given order item.",
46+
"type": "array",
47+
"items": {
48+
"type": "object",
49+
"properties": {
50+
"title": {
51+
"description": "Ticketing option short-description.",
52+
"type": "string",
53+
"readOnly": true,
54+
"enum": [
55+
"HOMEPRINT",
56+
"TICKETLESS",
57+
"PRINT_AT_KIOSK",
58+
"SECURE_PAPER"
59+
]
60+
},
61+
"selected": {
62+
"description": "Flag to specify which ticketing option is selected. Only one option is allowed to be selected.",
63+
"type": "boolean",
64+
"example": true
65+
},
66+
"additionalRequiredInfo": {
67+
"description": "Additional passenger required info specific to the given ticketing option.",
68+
"type": "string"
69+
},
70+
"deliveryInfo": {
71+
"description": "Data for ticket delivery.",
72+
"type": "object",
73+
"properties": {
74+
"availableDeliveryTypes": {
75+
"type": "array",
76+
"items": {
77+
"type": "string",
78+
"enum": [
79+
"POSTAL",
80+
"PICK_UP_STATION",
81+
"E-MAIL",
82+
"LOYALTY_CARD"
83+
]
84+
}
85+
},
86+
"ticketRecipients": {
87+
"type": "array",
88+
"items": {
89+
"type": "string",
90+
"enum": [
91+
"BOOKER",
92+
"CUSTOMER",
93+
"PASSENGER",
94+
"THIRD_PARTY"
95+
]
96+
}
97+
},
98+
"ccEmail": {
99+
"type": "string",
100+
"format": "email"
101+
},
102+
"postalAddress": {
103+
"$ref": "../Address/Address.v0-1.yaml"
104+
},
105+
"pickUpAtStation": {
106+
"description": "The name of the Station in case you select pick up at station as a delivery type",
107+
"type": "string"
108+
}
109+
}
110+
}
111+
}
112+
}
113+
}
114+
}
115+
}
116+
}
117+
}
118+
}
119+
}
120+
}
121+
}

src/components/SchemaRow.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ export const SchemaRow: React.FunctionComponent<ISchemaRow> = ({ node, treeStore
2929

3030
const type = isRef(schemaNode) ? '$ref' : isCombiner(schemaNode) ? schemaNode.combiner : schemaNode.type;
3131
const description = get(schemaNode, 'annotations.description');
32-
const childrenCount = size(get(schemaNode, 'properties'));
32+
const childrenCount =
33+
type === 'object'
34+
? size(get(schemaNode, 'properties'))
35+
: subtype === 'object'
36+
? size(get(schemaNode, 'items.properties'))
37+
: size(get(schemaNode, 'items'));
3338

3439
const nodeValidations = {
3540
...('annotations' in schemaNode && schemaNode.annotations.default

0 commit comments

Comments
 (0)