@@ -57,15 +57,28 @@ public async Task<HttpRequestMessage> BuildRequest(FormulaValue[] args, IConvert
57
57
// Header names are not case sensitive.
58
58
// From RFC 2616 - "Hypertext Transfer Protocol -- HTTP/1.1", Section 4.2, "Message Headers"
59
59
var headers = new Dictionary < string , string > ( StringComparer . OrdinalIgnoreCase ) ;
60
- Dictionary < string , ( ISwaggerSchema , FormulaValue ) > bodyParts = new ( ) ;
60
+ Dictionary < string , ( ISwaggerSchema , FormulaValue ) > bodyParts = new ( ) ;
61
61
Dictionary < string , FormulaValue > incomingParameters = ConvertToNamedParameters ( args ) ;
62
62
string contentType = null ;
63
63
64
64
foreach ( KeyValuePair < ConnectorParameter , FormulaValue > param in _function . _internals . OpenApiBodyParameters )
65
- {
65
+ {
66
66
if ( incomingParameters . TryGetValue ( param . Key . Name , out var paramValue ) )
67
67
{
68
- bodyParts . Add ( param . Key . Name , ( param . Key . Schema , paramValue ) ) ;
68
+ if ( _function . _internals . SpecialBodyHandling && paramValue is RecordValue rv )
69
+ {
70
+ foreach ( NamedValue field in rv . Fields )
71
+ {
72
+ string type = FormulaValueSerializer . GetType ( field . Value . Type ) ;
73
+ string format = FormulaValueSerializer . GetFormat ( field . Value . Type ) ;
74
+
75
+ bodyParts . Add ( field . Name , ( new SwaggerSchema ( type , format ) , field . Value ) ) ;
76
+ }
77
+ }
78
+ else
79
+ {
80
+ bodyParts . Add ( param . Key . Name , ( param . Key . Schema , paramValue ) ) ;
81
+ }
69
82
}
70
83
else if ( param . Key . Schema . Default != null && param . Value != null )
71
84
{
@@ -200,6 +213,7 @@ public Dictionary<string, FormulaValue> ConvertToNamedParameters(FormulaValue[]
200
213
// Parameter names are case sensitive.
201
214
202
215
Dictionary < string , FormulaValue > map = new ( ) ;
216
+ bool specialBodyHandling = _function . _internals . SpecialBodyHandling ;
203
217
204
218
// Seed with default values. This will get overwritten if provided.
205
219
foreach ( KeyValuePair < string , ( bool required , FormulaValue fValue , DType dType ) > kv in _function . _internals . ParameterDefaultValues )
@@ -217,9 +231,9 @@ public Dictionary<string, FormulaValue> ConvertToNamedParameters(FormulaValue[]
217
231
{
218
232
string parameterName = _function . RequiredParameters [ i ] . Name ;
219
233
FormulaValue paramValue = args [ i ] ;
220
-
234
+
221
235
// Objects are always flattenned
222
- if ( paramValue is RecordValue record && ! _function . RequiredParameters [ i ] . IsBodyParameter )
236
+ if ( paramValue is RecordValue record && ( specialBodyHandling || ! _function . RequiredParameters [ i ] . IsBodyParameter ) )
223
237
{
224
238
foreach ( NamedValue field in record . Fields )
225
239
{
0 commit comments