Skip to content

feat(wrapper-generator): complete v1.0 request-body binding - #3722

Open
Joywambui-maina wants to merge 3 commits into
feature/wrapper-module-packagingfrom
feat/bind-request-body-properties
Open

feat(wrapper-generator): complete v1.0 request-body binding#3722
Joywambui-maina wants to merge 3 commits into
feature/wrapper-module-packagingfrom
feat/bind-request-body-properties

Conversation

@Joywambui-maina

Copy link
Copy Markdown

Changes proposed in this pull request

  • Replace primitive-only request-body extraction with exhaustive property classification for the operations the WrapperGenerator emits.
  • Bind referenced Kiota models, enums, collections, formatted scalar types, nullable references, and numeric INF/NaN unions using their generated Kiota member types.
  • Bind schema-less properties as object and convert them to Kiota UntypedValue instances during assignment.
  • Replace the generated -Password and -ForceChangePasswordNextSignIn parameters with the published -PasswordProfile model parameter.
  • Preserve the published SDK's null-omission behavior for untyped values.
  • Add independent omission, coverage, inventory, compilation, and runtime-conversion gates.
  • Document the supported mappings, exclusion policies, scope boundary, and retained zero-population classifications.

Scope

This changes property binding only for operations that already generate. It does not add support for skipped actions, functions, unsupported path segments, or operations without a named request entity.

The operation-inventory gate verifies that this change does not alter which operations generate.

Validation

  • 148 WrapperGenerator tests pass.
  • All 38 v1.0 KiotaCompat specifications were measured.
  • The omission oracle reports zero failures across 2,214 generated body-writing cmdlets.
  • The coverage sweep reports zero unbound properties among operations that generate.
  • All 35 modules that produce wrapper manifests build and import successfully.
  • Runtime checks cover typed models, enums, Kiota Date, and 19 schema-less value-conversion cases.
  • The generated operation inventory is unchanged by the body-binding work.

Dependency

This PR is intentionally based on feature/wrapper-module-packaging so reviewers see only the 24 files belonging to request-body binding. After #3698 merges into powershell-v3, this PR will be retargeted to powershell-v3.

Closes #3707

Request bodies bound only top-level primitives, so 4,466 property
occurrences across the v1.0 specs had no parameter. Every shape the
classifier reaches now binds: referenced models and enums, formatted
strings, schema-less UntypedNode values (converted on assignment, nulls
dropped to match the published SDK's AddIf), and the numeric INF/NaN
union. The invented -Password pair is replaced by the published
-PasswordProfile. New gates verify it - omission oracle, coverage sweep,
inventory diff, runtime conversions: 0 unbound across all 38 specs, 35
modules build and import, 148 tests. The pre-existing naming-parity gap
is tracked separately.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the WrapperGenerator’s request-body parameter binding from “top-level primitives only” to a comprehensive classifier-driven binding model aligned with the Kiota-generated CLR types, and adds documentation + tooling gates to validate binding coverage, runtime conversions, and operation inventory stability.

Changes:

  • Introduces exhaustive request-body property classification (scalars, referenced models/enums/collections, schema-less/untyped, excluded-by-policy, unsupported shapes) and wires it into cmdlet emission for New/Update.
  • Adds runtime conversion support for schema-less properties via an emitted UntypedValue.From(object) helper, plus additional generator logging and validation scripts (coverage oracle, measurement sweep, operation inventory diff).
  • Expands and reorganizes documentation for binding rules and edge cases; updates build/test scripts to support committed wrapper output and validation.

Reviewed changes

Copilot reviewed 22 out of 25 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/WrapperGenerator/StderrLogger.cs Adds configurable minimum log level for CLI runs.
tools/WrapperGenerator/Singularizer.cs Updates naming-rule commentary and preserves “Whois” behavior rationale.
tools/WrapperGenerator/SchemaProperties.cs Implements request-body property classifier + exclusion/unsupported shape model.
tools/WrapperGenerator/README.md Updates docs to reflect full body binding, committed output layout, and validation gates.
tools/WrapperGenerator/Program.cs Adds --log-level argument and wires it into stderr logging.
tools/WrapperGenerator/PowerShellWrapperGenerationService.cs Integrates classification/binding into New/Update emission and adds reconciliation logging.
tools/WrapperGenerator/edge-cases/naming-edge-cases.md Removes legacy path in favor of docs-based catalog location.
tools/WrapperGenerator/docs/edge-cases/naming-edge-cases.md Extends naming edge-case catalog with additional cases and wrapper-surface change note.
tools/WrapperGenerator/docs/edge-cases/kiota-alignment-edge-cases.md Adds catalog of Kiota-vs-prediction alignment findings and encoded rules.
tools/WrapperGenerator/docs/edge-cases/crosspath-merge-edge-cases.md Documents cross-path cmdlet-variant deferral policy and known cases.
tools/WrapperGenerator/docs/edge-cases/body-binding-edge-cases.md Documents residual unsupported body shapes and why they remain deferred.
tools/WrapperGenerator/docs/body-property-binding.md Adds authoritative binding spec, mapping tables, exclusions, and verification model.
tools/WrapperGenerator/CmdletEmitter.cs Emits complex/untyped parameters + assignments; adds UntypedValue helper and null-safe collection writes.
tools/WrapperGenerator.Tests/SpecShapeTests.cs Adds tests pinning spec/reader behaviors relied on by binding (nav-property extension, nullable ref shape, enum refs).
tools/WrapperGenerator.Tests/SchemaPropertiesTests.cs Adds extensive classifier tests (formats, unions, exclusions, collisions, accounting invariants).
tools/WrapperGenerator.Tests/NamingTests.cs Updates deliberate-correction commentary (contains a small typo).
tools/WrapperGenerator.Tests/EmitterTests.cs Extends emitter tests to cover complex typed parameters and confirms password special-case removal.
tools/Test-WrapperModule.ps1 Adds stale-binary gate + runtime binding checks for complex/enums/scalars/untyped conversion matrix.
tools/Test-BodyBindingCoverage.ps1 Adds independent oracle to ensure every settable Kiota body member is bound or policy-cited.
tools/New-WrapperOutputManifest.ps1 Adds manifest generator for reviewable inventory of committed wrapper output under src/.
tools/Measure-BodyPropertyCoverage.ps1 Adds sweep script summarizing unbound properties by shape across all specs.
tools/Compare-WrapperOperationInventory.ps1 Adds inventory diff tool to ensure parameter-only changes don’t alter generated operations.
tools/Compare-WrapperCmdletNames.ps1 Small doc/comment updates for deliberate correction policy linkage.
tools/Build-WrapperModule.ps1 Adds -IntoSource to write the committed wrapper layout under src/<Module>/<ApiVersion>/wrapper/.
.gitignore Un-ignores src/BackupRestore/ so the module folder can be committed.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 141 to 145
// Deliberate corrections: the published name is wrong (an AutoRest naming defect) and the
// generator emits the corrected name instead of reproducing it. Every entry here must have
// a docs/edge-cases/naming-edge-cases.md entry and a matching row in
// an docs/edge-cases/naming-edge-cases.md entry and a matching row in
// Compare-WrapperCmdletNames.ps1's $deliberateCorrections table, so the parity gate
// reports it as [CORRECTED], not a failure.
Comment on lines 665 to 668
public Task AuthenticateRequestAsync(RequestInformation request, Dictionary<string, object>? additionalAuthenticationContext = null, CancellationToken cancellationToken = default)
{
request.Headers.TryAdd("Authorization", $"Bearer {_token}");
return Task.CompletedTask;
Comment on lines +355 to +362
private static bool IsNullabilityPlaceholder(IOpenApiSchema schema) =>
(schema.Properties?.Count ?? 0) == 0
&& (schema.Enum?.Count ?? 0) == 0
&& schema.Items is null
&& schema.AdditionalProperties is null
&& string.IsNullOrEmpty(schema.Format)
&& (schema.AnyOf?.Count ?? 0) == 0
&& (schema.OneOf?.Count ?? 0) == 0;
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