Skip to content

Commit 9eb2c61

Browse files
authored
MoreApp Forms - Improve "Create task" action (#3636)
* Improve "Create task" action * Review comments
1 parent b051dd9 commit 9eb2c61

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

certified-connectors/MoreApp Forms/apiDefinition.swagger.json

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,31 @@
613613
],
614614
"description": "Downloads a report."
615615
}
616+
},
617+
"/api/v1.0/forms/customer/:customerId:/forms/{formId}/versions": {
618+
"get": {
619+
"responses": {
620+
"200": {
621+
"description": "default",
622+
"schema": {
623+
"type": "object"
624+
}
625+
}
626+
},
627+
"summary": "Get formVersion",
628+
"operationId": "GetFormVersion",
629+
"parameters": [
630+
{
631+
"name": "formId",
632+
"in": "path",
633+
"x-ms-summary": "formId",
634+
"description": "formId",
635+
"type": "string",
636+
"required": true
637+
}
638+
],
639+
"description": "Lists versions of a form"
640+
}
616641
}
617642
},
618643
"x-ms-connector-metadata": [
@@ -653,7 +678,16 @@
653678
"type": "string"
654679
},
655680
"data": {
656-
"type": "object"
681+
"type": "object",
682+
"x-ms-dynamic-schema": {
683+
"operationId": "GetFormVersion",
684+
"value-path": "schema",
685+
"parameters": {
686+
"formId": {
687+
"parameter": "formId"
688+
}
689+
}
690+
}
657691
},
658692
"publishInfo": {
659693
"type": "object",

certified-connectors/MoreApp Forms/script.csx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
public class Script : ScriptBase
1+
public class Script : ScriptBase
22
{
33
public override async Task<HttpResponseMessage> ExecuteAsync()
44
{
@@ -57,6 +57,36 @@
5757
return reportResponse;
5858
}
5959

60+
// Create an OpenAPI schema from a formVersion
61+
// Runs only for GetFormVersion
62+
if (this.Context.OperationId == "GetFormVersion")
63+
{
64+
JArray responseBody = JArray.Parse(await response.Content.ReadAsStringAsync().ConfigureAwait(false));
65+
JArray fields = (JArray) responseBody[0]["fields"];
66+
JObject properties = new JObject();
67+
68+
foreach (JObject field in fields)
69+
{
70+
JObject fieldProperties = (JObject) field["properties"];
71+
if(fieldProperties.ContainsKey("data_name")) {
72+
JObject widget = new JObject();
73+
widget["oneOf"] = new JArray();
74+
((JArray) widget["oneOf"]).Add(new JObject{["type"] = "string"});
75+
((JArray) widget["oneOf"]).Add(new JObject{["type"] = "object"});
76+
widget["x-ms-summary"] = fieldProperties["label_text"];
77+
widget["description"] = fieldProperties["label_text"];
78+
properties[(string) fieldProperties["data_name"]] = widget;
79+
}
80+
}
81+
82+
var schema = new JObject();
83+
schema["type"] = "object";
84+
schema["properties"] = properties;
85+
var root = new JObject();
86+
root["schema"] = schema;
87+
response.Content = CreateJsonContent(root.ToString());
88+
}
89+
6090
return response;
6191
}
6292

0 commit comments

Comments
 (0)