Skip to content

Propagate x-ms-dynamic-schema through $ref resolution for body parameters#3032

Open
EricBuist wants to merge 1 commit intomicrosoft:mainfrom
EricBuist:users/ericbuist/extension-propagation
Open

Propagate x-ms-dynamic-schema through $ref resolution for body parameters#3032
EricBuist wants to merge 1 commit intomicrosoft:mainfrom
EricBuist:users/ericbuist/extension-propagation

Conversation

@EricBuist
Copy link
Contributor

When a body schema uses $ref (e.g., Excel Online's Item definition), x-ms-dynamic-schema lives on the referenced definition, not on its individual properties. The decomposition into property parameters was losing this extension, causing ContainsDynamicSchemaOrProperty to be false and preventing dynamic schema tool generation.

In ConnectorFunction.cs:1646, when the body of an OpenAPI operation has properties (e.g. bodySchema.Properties.Any()), PowerFx decomposes the body into individual property parameters. Each synthesized OpenApiParameter gets Extensions = bodyPropertySchema.Extensions — the extensions from the individual property schema, not from the parent body schema.

For Excel Online, the body parameter is "schema": { "$ref": "#/definitions/Item" }. The resolved Item definition has x-ms-dynamic-schema on itself (the parent), but its child property dynamicProperties does not. So the extension is lost during decomposition.

For SharePoint, the inline body schema has x-ms-dynamic-schema directly, which takes a different code path (schema-less body) where the extension is preserved.

Fix

File: src/libraries/Microsoft.PowerFx.Connectors/ConnectorFunction.cs

Added propagation of x-ms-dynamic-schema and x-ms-dynamic-properties from the parent bodySchema to the synthesized property parameter when the property doesn't already have its own. The extensions dictionary is cloned to avoid mutating the original schema.

Test

File: src/tests/Microsoft.PowerFx.Connectors.Tests.Shared/PowerPlatformConnectorTests.cs

Added ExcelOnlineAddRowV2_ItemParamHasDynamicSchema — a [Theory] with both UseItemDynamicPropertiesSpecialHandling true/false, verifying that SupportsDynamicSchemaOrProperty is true on the item parameter for both AddRowV2 and PatchItem operations.

Fixes AB#37071606

…ters

When a body schema uses $ref (e.g., Excel Online's Item definition),
x-ms-dynamic-schema lives on the referenced definition, not on its
individual properties. The decomposition into property parameters was
losing this extension, causing ContainsDynamicSchemaOrProperty to be
false and preventing dynamic schema tool generation.

Fixes AB#37071606

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@EricBuist EricBuist requested a review from a team as a code owner March 13, 2026 15:03
// to property parameters when the property doesn't have its own.
// This handles $ref body schemas (e.g., Excel Online's Item definition) where
// x-ms-dynamic-schema is on the referenced definition, not on individual properties.
IDictionary<string, IOpenApiExtension> bodyParamExtensions = bodyPropertySchema.Extensions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we fix the swagger.
but a generic fix like this to the library is ok, provided it doesn't break anything else.

We just want to avoid per-connector specific code in the library. (which you avoid here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that. Even Copilot Studio Engine should be free of connector-specific kludges. I took a look at the Excel Online (business) Swagger and without the PowerFx fix, they would need to move the x-ms-dynamic-schema extension from a commonly used reference to duplicate it in each parameter that needs the schema. Tell me if I'm wrong but seems better to fix it in PowerFx so it is possible reuse the x-ms-dynamic-schema declaration across multiple parameter instances in different operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants