Skip to content

zendern/sse-kiota-example

Repository files navigation

sse kiota example

Uses uv and fastapi.

Important files

FastAPI backend sending SSE

OpenAPI Spec doc

Python client SSE test

Typescript client SSE test

How to generate client

Pre-reqs

Note

There is a devcontainer you should just use that but here is a list of things you'll need if not

  1. Install uv (ran originally with 0.10.7)
  2. Install docker
  3. Install npm/node (ran originally with Node 24)

How to generate kiota clients for typescript and python

uv sync
uv run python generate.py

rm -rf generated/python && mkdir -p generated/python
docker run --user $(id -u):$(id -g) -v "./generated/python:/app/output" -v "./openapi.json:/app/openapi.json" mcr.microsoft.com/openapi/kiota:1.30.0 "generate" -l python -c PythonClient -n client -d openapi.json --exclude-backward-compatible --clean-output --additional-data false

rm -rf app/generated/typescript  && mkdir -p app/generated/typescript
docker run --user $(id -u):$(id -g) -v "./generated/typescript:/app/output" -v "./openapi.json:/app/openapi.json" mcr.microsoft.com/openapi/kiota:1.30.0 "generate" -l typescript -c FrontendClient -n client -d openapi.json --exclude-backward-compatible --clean-output --additional-data false

Running the example

Prerequisites

  1. Install dependencies: uv sync

Start the FastAPI server

In one terminal window, start the FastAPI server using uv:

uv run fastapi dev

The server will start on http://localhost:8000. You should see output like:

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)

Run the Python client verification script

In another terminal window, run the python verification script:

uv run python verify_sse_client.py

Note

Notice it'll run infinitely and not return any data as the client expects a full response before handling it.

Running typescript client verification

In another terminal window, run the typescript verification script:

cd app
npm run dev

Note

Notice it'll run infinitely and not return any data as the client expects a full response before handling it.

About

typescript and python SSE example using kiota clients

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors