Skip to main content

zopy-takibiapi

TakibiAPI with zopy (Zod for Python) schemas, checked strictly: checks, unknown keys and responses included.

pip install zopy-takibiapi

Quick start

from zopy_takibiapi import Context, OpenAPIObject, TakibiAPI, createRoute, z


class Message(OpenAPIObject, openapi="Message"):  # components.schemas.Message, referenced with $ref
    message = z.string().openapi({"example": "takibi🔥"})


class getTakibiRoute(
    createRoute(
        {
            "method": "get",
            "path": "/takibi",
            "responses": {200: {"description": "takibi🔥", "content": {"application/json": {"schema": Message}}}},
        }
    )
):
    """Say takibi🔥."""


def getTakibiRouteHandler(c: Context[getTakibiRoute]):
    return c.json(Message(message="takibi🔥"), 200)


app = TakibiAPI()
app.openapi(getTakibiRoute, getTakibiRouteHandler)
app.doc("/doc", {"openapi": "3.0.0", "info": {"title": "takibi API", "version": "1.0.0"}})
granian --interface rsgi myapp:app   # or: uvicorn myapp:app
curl localhost:8000/takibi           # {"message":"takibi🔥"}

Import TakibiAPI, OpenAPIObject and z from zopy_takibiapi; everything else works as in Takibi.

Schemas

Every object, nested ones included, must be z.StrictObject (or OpenAPIObject, which is one); app.openapi raises TypeError for a loose object or a non-zopy schema. Parameters arrive as text and are parsed as Zod parses them, so convert explicitly: todoId = z.coerce.number().int().

Checks

  • Requests: c.req.valid(...) gives the parsed value. A failure gets 422 with Zod's issue codes as code.
  • Responses: c.json(value, status) encodes value with the schema declared for that status (safeEncode: checked, codecs to their wire form). A mismatch raises ResponseValidationError and answers 500 (details in the log, not in the response).
app.onError(lambda c: c.json({"error": str(c.error)}, 500))  # replaces the 500, ResponseValidationError included

OpenAPI

The OpenAPI metadata is written with the schema, as in @hono/zod-openapi:

class Todo(OpenAPIObject, openapi="Todo"):  # z.object({...}).openapi("Todo")
    id = z.int().positive().openapi({"example": 1})
    title = z.string().openapi({"description": "What to do"})


class Tag(OpenAPIObject, openapi={"id": "Tag", "description": "A label"}):  # a name and metadata
    name = z.string()

OpenAPIObject is a z.StrictObject whose class keyword openapi= names it: the class itself becomes components.schemas.Todo, referenced with $ref wherever it is used, so one name serves as the route's schema and as the type the handler returns (c.json(Todo(...))). A mapping without "id" adds metadata only, and a subclass is unnamed until it says otherwise. zopy's Todo.openapi("Todo") still works, but names a copy of the class.

As in Zod, only named schemas become components; others are written in place. Documents come from zopy's toJSONSchema (openapi-3.0 or JSON Schema 2020-12).

Development

From the repository root: uv run pytest packages/zopy-takibiapi. See the root README.

License

Distributed under the MIT License. See LICENSE for more information.

Metadata

Release files for zopy-takibiapi 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zopy-takibiapi 0.3.0
File Size Uploaded Provenance Actions
zopy_takibiapi-0.3.0.tar.gz 8.2 kB With provenance Details for zopy_takibiapi-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zopy-takibiapi 0.3.0
File Interpreter ABI Platform Actions
zopy_takibiapi-0.3.0-py3-none-any.whl Python 3 none any Details for zopy_takibiapi-0.3.0-py3-none-any.whl

Total release size: 18.5 kB

Release files / zopy_takibiapi-0.3.0.tar.gz

Download URL zopy_takibiapi-0.3.0.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
03bab53c7a635094e35fd0344017b45a30be1529f27203e36512c346efcae233
BLAKE2b-256 checksum
How to use checksums
7d9a2391a9a3de44f46942b25bdefebeed1459a508dde36378249491e7f1a167
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / zopy_takibiapi-0.3.0-py3-none-any.whl

Download URL zopy_takibiapi-0.3.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41b4a0b2b5040a6f7d9432f4910d19ca2502ba1ef3a6543cfc7dd4ccd2a4c4d0
BLAKE2b-256 checksum
How to use checksums
62802da22822a75a04ec1f00bbbcb1be523d0084f0896bc15f22153e01827ce9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for zopy-takibiapi 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zopy_takibiapi-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page