Skip to content

Commit d458a96

Browse files
committed
add schema extensions for simple types
1 parent 77cf6ac commit d458a96

File tree

2 files changed

+125
-5
lines changed

2 files changed

+125
-5
lines changed

properties_pane/field_level/fieldLevelConfig.json

Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,32 @@ making sure that you maintain a proper JSON format.
588588
],
589589
"enableForReference": true
590590
},
591-
"comments"
591+
"comments",
592+
{
593+
"propertyName": "extensions",
594+
"propertyType": "group",
595+
"propertyKeyword": "scopesExtensions",
596+
"shouldValidate": true,
597+
"propertyTooltip": "",
598+
"structure": [
599+
{
600+
"propertyName": "pattern",
601+
"propertyKeyword": "extensionPattern",
602+
"shouldValidate": true,
603+
"propertyType": "text",
604+
"regex":"^x-"
605+
},
606+
{
607+
"propertyName": "value",
608+
"propertyKeyword": "extensionValue",
609+
"propertyValidate": false,
610+
"propertyTooltip": "Popup for multi-line text entry",
611+
"propertyType": "details",
612+
"template": "textarea",
613+
"markdown": false
614+
}
615+
]
616+
}
592617
],
593618
"number": [
594619
{
@@ -873,7 +898,32 @@ making sure that you maintain a proper JSON format.
873898
],
874899
"enableForReference": true
875900
},
876-
"comments"
901+
"comments",
902+
{
903+
"propertyName": "extensions",
904+
"propertyType": "group",
905+
"propertyKeyword": "scopesExtensions",
906+
"shouldValidate": true,
907+
"propertyTooltip": "",
908+
"structure": [
909+
{
910+
"propertyName": "pattern",
911+
"propertyKeyword": "extensionPattern",
912+
"shouldValidate": true,
913+
"propertyType": "text",
914+
"regex":"^x-"
915+
},
916+
{
917+
"propertyName": "value",
918+
"propertyKeyword": "extensionValue",
919+
"propertyValidate": false,
920+
"propertyTooltip": "Popup for multi-line text entry",
921+
"propertyType": "details",
922+
"template": "textarea",
923+
"markdown": false
924+
}
925+
]
926+
}
877927
],
878928
"integer": [
879929
{
@@ -1159,7 +1209,32 @@ making sure that you maintain a proper JSON format.
11591209
],
11601210
"enableForReference": true
11611211
},
1162-
"comments"
1212+
"comments",
1213+
{
1214+
"propertyName": "extensions",
1215+
"propertyType": "group",
1216+
"propertyKeyword": "scopesExtensions",
1217+
"shouldValidate": true,
1218+
"propertyTooltip": "",
1219+
"structure": [
1220+
{
1221+
"propertyName": "pattern",
1222+
"propertyKeyword": "extensionPattern",
1223+
"shouldValidate": true,
1224+
"propertyType": "text",
1225+
"regex":"^x-"
1226+
},
1227+
{
1228+
"propertyName": "value",
1229+
"propertyKeyword": "extensionValue",
1230+
"propertyValidate": false,
1231+
"propertyTooltip": "Popup for multi-line text entry",
1232+
"propertyType": "details",
1233+
"template": "textarea",
1234+
"markdown": false
1235+
}
1236+
]
1237+
}
11631238
],
11641239
"boolean": [
11651240
{
@@ -1435,7 +1510,39 @@ making sure that you maintain a proper JSON format.
14351510
"propertyType": "text",
14361511
"shouldValidate": true
14371512
},
1438-
"comments"
1513+
"comments",
1514+
{
1515+
"propertyName": "nullable",
1516+
"propertyKeyword": "nullable",
1517+
"propertyType": "checkbox",
1518+
"enableForReference": true
1519+
},
1520+
"comments",
1521+
{
1522+
"propertyName": "extensions",
1523+
"propertyType": "group",
1524+
"propertyKeyword": "scopesExtensions",
1525+
"shouldValidate": true,
1526+
"propertyTooltip": "",
1527+
"structure": [
1528+
{
1529+
"propertyName": "pattern",
1530+
"propertyKeyword": "extensionPattern",
1531+
"shouldValidate": true,
1532+
"propertyType": "text",
1533+
"regex":"^x-"
1534+
},
1535+
{
1536+
"propertyName": "value",
1537+
"propertyKeyword": "extensionValue",
1538+
"propertyValidate": false,
1539+
"propertyTooltip": "Popup for multi-line text entry",
1540+
"propertyType": "details",
1541+
"template": "textarea",
1542+
"markdown": false
1543+
}
1544+
]
1545+
}
14391546
],
14401547
"array": [
14411548
{

reverse_engineering/helpers/dataHelper.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,18 @@ const convertFormatToMode = schema => {
582582
}
583583
};
584584

585+
const handleSchemaExtensions = (schema) => {
586+
const mappedExtensionsObject = getExtensionsObject(schema);
587+
const schemaWithoutExtensions = Object.keys(schema).reduce((accumulator, property) => {
588+
if (property.startsWith(EXTENSION_SYMBOL)) {
589+
return accumulator;
590+
}
591+
return Object.assign({}, accumulator, {[property]: schema[property]});
592+
}, {});
593+
594+
return Object.assign({}, schemaWithoutExtensions, mappedExtensionsObject);
595+
};
596+
585597
const handleSchemaProps = (schema, fieldOrder) => {
586598
if (!schema) {
587599
schema = {
@@ -590,7 +602,8 @@ const handleSchemaProps = (schema, fieldOrder) => {
590602
}
591603

592604
const fixedSchema = convertFormatToMode(setMissedType(schema));
593-
const schemaWithAdditionalPropertiesData = handleAdditionalProperties(fixedSchema);
605+
const schemaWithExtensions = handleSchemaExtensions(fixedSchema);
606+
const schemaWithAdditionalPropertiesData = handleAdditionalProperties(schemaWithExtensions);
594607
const schemaWithChoices = handleSchemaChoices(schemaWithAdditionalPropertiesData, fieldOrder);
595608
const reorderedSchema = commonHelper.reorderFields(schemaWithChoices, fieldOrder);
596609
const schemaWithHandledProperties = Object.keys(reorderedSchema).reduce((accumulator, property) => {

0 commit comments

Comments
 (0)