Skip to content

feat(samples): add the Kiota extensions demo - #972

Merged
kazo0 merged 1 commit into
masterfrom
dev/sb/kiota-extensions-demo
Nov 7, 2026
Merged

kazo0 merged 1 commit into
masterfrom
dev/sb/kiota-extensions-demo

Conversation

@kazo0

@kazo0 kazo0 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Adds UI/Http.KiotaExtensionsDemo, a single-project Uno app whose every HTTP call goes through a client the Kiota CLI generated from an OpenAPI document, registered with Uno.Extensions.Http.Kiota. It is design-first: Specs/TasksApi.yaml is the contract, the included server (Http.KiotaExtensionsDemo.Server, the template's -server project) implements it, and the app's client is generated from it.

The sample was built by an agent from the uno-kiota skill alone, as a test of that skill (unoplatform/studio#215); the places the skill was wrong were fixed there.

What it demonstrates

  • A contract that exercises Kiota's edge cases: JSON CRUD, query and path parameters, an enum and dates, a typed 404 (ApiError), 400 validation errors as application/problem+json shown per field, a text/plain status line, a multipart/form-data upload, and a report that answers 503 with Retry-After while it warms up.
  • A registration that works around [Http][Kiota] Only JSON serializer is added uno.extensions#2799: AddKiotaClient gives the request adapter only Kiota's JSON factories, so the text/plain, multipart and problem+json operations would all throw expected a application/json content type. Services/TasksApiSetup.cs does what AddKiotaClient does with every serializer and still attaches Kiota's middleware, so the warm-up 503s are retried.
  • The base URL per environment and head: ApiClient:Url in both appsettings files (without it the generated client silently calls the contract's placeholder servers URL), passed as options so trimmed builds keep it ([Http] AddRefitClient and AddKiotaClient lose the endpoint Url in trimmed builds ("BaseAddress must be set on the HttpClient instance") uno.extensions#3266), the page's origin on WebAssembly, and 10.0.2.2 on the Android emulator.
  • Kiota types stay behind one service: Services/TasksService.cs maps the generated models to the app's records, turns the error models into app exceptions, and reads the additionalProperties maps (validation errors, byPriority) from Kiota's untyped nodes. MVUX Models only see records.
  • Headless tests of every operation: 21 NUnit tests run each call through the app's own registration against the server in-process (WebApplicationFactory), including tests that pin the plain-AddKiotaClient failures so the fix of [Http][Kiota] Only JSON serializer is added uno.extensions#2799 shows up as a failing test.
  • Regenerating with an agent or by hand: dotnet-tools.json pins Kiota 1.37 as a local tool; the README's "Change the API" section is the step list (edit the contract, update the server, dotnet kiota update, map, test).

Running it

Start the server (dotnet run --project Http.KiotaExtensionsDemo.Server, port 5001), then run a head. The README covers each head and troubleshooting.

Packages

Uno.Sdk 7.0.0-dev.115
Uno.Extensions (pinned by the Sdk) 8.0.0-dev.150
Microsoft.Kiota.* runtime (from HttpKiota) 1.22.2
Kiota CLI (local tool, kiota-lock.json) 1.37.0

The csproj keeps the Debug-only Uno.WinUI.Lottie reference (unoplatform/uno.extensions#3262) and skips Uno's ICU initializer on the plain net10.0 target, without which the test project fails with Failed to load 'icuuc77'.

Tested

  • 21 headless tests pass (dotnet test Http.KiotaExtensionsDemo.Tests).
  • Desktop (Skia) on Windows, Debug and Release: the list, status line and summary load (the summary after the two 503 retries, about 2 s), with no exceptions in the log; Release calls the configured server, not the placeholder.
  • The "Change the API" steps, end to end on a copy: a new field added to the contract and the server, the client regenerated with dotnet kiota update, a new test passing.
  • WebAssembly and Android: built, not run.
  • iOS: not built (needs macOS).
  • In-app interactions (validation messages on screen, upload through the picker, edit, delete) are covered by the service tests, not yet exercised through the UI.

🤖 Generated with Claude Code

https://claude.ai/code/session_013G4Ls3q7cwW8sSEg5YgWHF

A design-first task manager: Specs/TasksApi.yaml is the contract, the
server implements it, and the app's client is generated from it with the
Kiota CLI (pinned as a local tool in dotnet-tools.json). It covers JSON
CRUD, query and path parameters, a typed 404, problem+json validation
errors read per field, a text/plain status, a multipart upload and a 503
warm-up that Kiota's retry handler rides out. 21 headless tests run every
operation through the app's own registration against the server
in-process.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013G4Ls3q7cwW8sSEg5YgWHF
@kazo0
kazo0 merged commit 2ebd74d into master Nov 7, 2026
10 checks passed
@kazo0
kazo0 deleted the dev/sb/kiota-extensions-demo branch November 7, 2026 23:57
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.

1 participant