Metadata-Version: 2.4
Name: takibi-swagger-ui
Version: 0.1.1
Summary: Swagger UI middleware for a takibiapi app
Keywords: openapi,swagger-ui,asgi,takibiapi
Author: nakita628
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Typing :: Typed
Requires-Dist: takibiapi>=0.1.0,<0.2
Requires-Python: >=3.12
Project-URL: Repository, https://github.com/nakita628/takibiapi
Project-URL: Issues, https://github.com/nakita628/takibiapi/issues
Description-Content-Type: text/markdown

# takibi-swagger-ui

Swagger UI for a [TakibiAPI](../takibiapi) app (or its [pydantic](../pydantic-takibiapi) / [zopy](../zopy-takibiapi) flavors), as Hono's [`@hono/swagger-ui`](https://github.com/honojs/middleware/tree/main/packages/swagger-ui).

```sh
pip install takibi-swagger-ui
```

```python
from takibiapi import TakibiAPI
from takibi_swagger_ui import swaggerUI

app = TakibiAPI()
# app.openapi(route, handler) ...
app.doc("/doc", {"openapi": "3.1.0", "info": {"title": "My API", "version": "1.0.0"}})
app.use(swaggerUI({"url": "/doc"}), prefix="/ui")  # GET /ui: the Swagger UI page
```

The page loads `swagger-ui-dist` from jsDelivr (`"version": "5.17.14"` pins it) and the document from `url`.

## Options

- `title`: the page's `<title>` (default `SwaggerUI`).
- `version`: the `swagger-ui-dist` version.
- `manuallySwaggerUIHtml`: `(asset) -> str`, the page body built from `asset["css"]` / `asset["js"]`.
- Everything else is [Swagger UI's configuration](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/) (`url`, `urls`, `spec`, `deepLinking`, `docExpansion`, `persistAuthorization`, ...), written as JSON. `presets`, `plugins`, `requestInterceptor`, `responseInterceptor`, `onComplete`, `operationsSorter`, `tagsSorter`, `modelPropertyMacro` and `parameterMacro` are JavaScript source and written as they are:

```python
swaggerUI({"url": "/doc", "requestInterceptor": "(req) => { req.headers['x-api-key'] = 'dev'; return req }"})
```

`SwaggerUI(options)` returns the markup alone, to put in a page of your own.

## Development

From the repository root: `uv run pytest packages/takibi-swagger-ui`. See the root README.

## License

Distributed under the MIT License. See [LICENSE](https://github.com/nakita628/takibiapi/blob/main/packages/takibi-swagger-ui/LICENSE) for more information.
