Skip to content

Handle inline arrays on trailing-slash paths - #8011

Open
AayushP123 wants to merge 1 commit into
microsoft:mainfrom
AayushP123:agent/fix-7876-trailing-slash-inline-array
Open

Handle inline arrays on trailing-slash paths#8011
AayushP123 wants to merge 1 commit into
microsoft:mainfrom
AayushP123:agent/fix-7876-trailing-slash-inline-array

Conversation

@AayushP123

Copy link
Copy Markdown
Contributor

Summary

Fixes #7876.

Uses the existing EmptyPathSegment placeholder when naming inline response models on trailing-slash paths. Without a fallback name, arrays of inline objects reached FindChildByName with an empty declaration name and aborted generation.

Changes

  • Allow GetClassName callers to provide a fallback for empty path segments.
  • Apply the trailing-slash placeholder to regular, inherited, and composed inline model declarations.
  • Add a regression test for an inline object array returned from /test/.
  • Add a changelog entry.

Testing

  • Generated the issue's Go client from the provided OpenAPI shape.
  • go test ./... on the generated client with Go 1.26.5.
  • dotnet format whitespace kiota.slnx --no-restore --verify-no-changes --include src/Kiota.Builder/Extensions/OpenApiUrlTreeNodeExtensions.cs src/Kiota.Builder/KiotaBuilder.cs tests/Kiota.Builder.Tests/KiotaBuilderTests.cs
  • dotnet test tests/Kiota.Builder.Tests/Kiota.Builder.Tests.csproj --no-restore (2,191 passed, 2 skipped)

Copilot AI review requested due to automatic review settings August 1, 2026 08:08

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.

🟢 Ready to approve

The fix is narrowly scoped, addresses the reported failure mode, and includes a targeted regression test validating the behavior.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Fixes a Kiota client-generation failure for trailing-slash paths (e.g., /test/) whose responses return an array of inline objects by ensuring inline model naming falls back to the existing EmptyPathSegment placeholder instead of producing an empty declaration name.

Changes:

  • Extended OpenApiUrlTreeNodeExtensions.GetClassName to accept an optional placeholder fallback used when the computed segment name is empty.
  • Applied the trailing-slash placeholder when deriving names for regular, inherited, and composed inline model declarations during model creation.
  • Added a regression test covering an inline object array response from a trailing-slash path, plus a changelog entry.
File summaries
File Description
tests/Kiota.Builder.Tests/KiotaBuilderTests.cs Adds regression coverage for /test/ returning an array of inline objects and verifies the inline model uses the trailing-slash placeholder name.
src/Kiota.Builder/KiotaBuilder.cs Passes the trailing-slash placeholder into inline model naming paths (regular/inherited/composed) to prevent empty declaration names.
src/Kiota.Builder/Extensions/OpenApiUrlTreeNodeExtensions.cs Adds a placeholder parameter to GetClassName and routes it to the shared segment-name logic.
CHANGELOG.md Documents the fix for trailing-slash inline-object-array generation.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@AayushP123
AayushP123 force-pushed the agent/fix-7876-trailing-slash-inline-array branch from 55f9d7e to ccee208 Compare August 1, 2026 09:10
@AayushP123
AayushP123 marked this pull request as ready for review August 2, 2026 08:39
@AayushP123
AayushP123 requested a review from a team as a code owner August 2, 2026 08:39
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.

Building fails with "childName cannot be empty"

2 participants