Skip to content

Declare response models for every route; add CI; drop httpx - #1

Merged
almas-alright merged 1 commit into
mainfrom
claude/keen-edison-tnfd8h
Oct 18, 2026
Merged

almas-alright merged 1 commit into
mainfrom
claude/keen-edison-tnfd8h

Conversation

@almas-alright

Copy link
Copy Markdown
Contributor

Makes pairkit's HTTP API self-describing, adds CI, and removes a stalled dependency.

What changed

  • Response models in fastapi.py: OfferCreated, Claimed, OfferStatus, Collected and LinkedDeviceOut. /events is declared as text/event-stream, listing its event names.
    • An app's /openapi.json now describes pairing responses exactly, so clients can generate their types. ScribbleScan-web currently writes these by hand.
    • The JSON doesn't change. qr_url is still left out when there's no scan_url. Collected allows extra fields, so whatever an app puts in Grant.data (ScribbleScan's space_id) still comes through.
  • Tests (now 20):
    • every route publishes a response schema
    • qr_url is omitted without a scan_url
    • the existing HTTP test already covers extra grant data passing through
  • CI: ruff and pytest on Python 3.12 (the oldest supported) and 3.14.
  • httpx removed from the dev dependencies. It has had no stable release since December 2024, and FastAPI's TestClient already uses httpx2.
  • Roadmap: suggests a Postgres store (LISTEN/NOTIFY) instead of Redis, for apps that already run Postgres, as ScribbleScan does.

Compatibility

Public Python API unchanged. ScribbleScan installs pairkit from main. Once this is merged, I'll update ScribbleScan's lock so its own OpenAPI contract test also covers /v1/pair/*, and switch ScribbleScan-web to the generated types.


Generated by Claude Code

- fastapi.py: OfferCreated, Claimed, OfferStatus, Collected and
  LinkedDeviceOut response models, plus a text/event-stream response
  for /events. Apps' OpenAPI specs now describe pairing responses
  exactly, so clients (like ScribbleScan-web) can generate their types
  instead of writing them by hand. The JSON is unchanged: qr_url is
  still left out without a scan_url, and Collected keeps whatever the
  app put in Grant.data.
- Tests: every route has a response schema; no qr_url without a
  scan_url (20 tests).
- CI: ruff and pytest on Python 3.12 and 3.14.
- Dev dependencies no longer include httpx, which is stalled; FastAPI's
  TestClient already uses httpx2.
- Roadmap: a Postgres store (LISTEN/NOTIFY) instead of Redis, for apps
  that already run Postgres.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A5s1B8CvD6MoPSJZpL8ScT
@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: abdea0c1-02cf-49bd-926e-e2d12b4ef243
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T15:09:11.689905Z 8b7d923 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@almas-alright almas-alright left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

okay

@almas-alright
almas-alright merged commit e088ea4 into main Oct 18, 2026
5 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b7d92356a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/pairkit/fastapi.py
class Collected(BaseModel):
"""The grant from the app's issue_grant hook, plus whatever it put in Grant.data."""

model_config = ConfigDict(extra="allow")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve Grant.data under Pydantic v1

Apps using the still-permitted FastAPI 0.110/Pydantic v1 stack regress here: Pydantic v1 treats model_config as a normal response field and leaves its default extra policy as ignore, so /collect silently drops fields supplied through Grant.data (such as space_id) and emits a spurious model_config field. Older permitted Pydantic v1 releases also cannot import ConfigDict at all. Use the v1-compatible Config mechanism (or explicitly require Pydantic v2) before relying on this response model.

Useful? React with 👍 / 👎.

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