https://github.com/luolingchun/star-openapi
A simple async API framework based on Starlette.
https://github.com/luolingchun/star-openapi
openapi openapi3 pydantic python3 redoc scalar starlette swagger
Last synced: 3 months ago
JSON representation
A simple async API framework based on Starlette.
- Host: GitHub
- URL: https://github.com/luolingchun/star-openapi
- Owner: luolingchun
- License: mit
- Created: 2026-01-04T08:08:58.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-01-12T06:21:10.000Z (3 months ago)
- Last Synced: 2026-01-12T15:37:49.337Z (3 months ago)
- Topics: openapi, openapi3, pydantic, python3, redoc, scalar, starlette, swagger
- Language: Python
- Homepage: https://luolingchun.github.io/star-openapi/
- Size: 1.47 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
A simple async API framework based on Starlette.
**Star OpenAPI** is a web API framework based on **Starlette**. It uses **Pydantic** to verify data and automatic
generation of interaction documentation.
The key features are:
- **Easy to code:** Easy to use and easy to learn
- **Standard document specification:** Based on [OpenAPI Specification](https://spec.openapis.org/oas/v3.1.0)
- **Interactive OpenAPI documentation:**
[Swagger](https://github.com/swagger-api/swagger-ui), [Redoc](https://github.com/Redocly/redoc), [RapiDoc](https://github.com/rapi-doc/RapiDoc), [RapiPdf](https://mrin9.github.io/RapiPdf/), [Scalar](https://github.com/scalar/scalar), [Elements](https://github.com/stoplightio/elements)
- **Data validation:** Fast data verification based on [Pydantic](https://github.com/pydantic/pydantic)
- **Websocket**: Support for websocket
## Requirements
Python 3.11+
star-openapi is dependent on the following libraries:
- [Starlette](https://github.com/Kludex/starlette) for the web app.
- [Pydantic](https://github.com/pydantic/pydantic) for the data validation.
## Installation
```bash
pip install -U star-openapi[swagger]
```
Optional dependencies
- [`httpx`](https://github.com/encode/httpx/) - Required if you want to use the `TestClient`.
- [`python-multipart`](https://github.com//kludex/python-multipart) - Required if you want to support form parsing, with
`request.form()`.
- [`itsdangerous`](https://github.com/pallets/itsdangerous) - Required for `SessionMiddleware` support.
- [`pyyaml`](https://github.com/yaml/pyyaml) - Required for `SchemaGenerator` support.
You can install all of these with `pip install star-openapi[full]`.
- [star-openapi-plugins](https://github.com/luolingchun/star-openapi-plugins) Provide OpenAPI UI for star-openapi.
You can install all of these with `pip install star-openapi[swagger,redoc,rapidoc,rapipdf,scalar,elements]`.
## A Simple Example
Here's a simple example, further go to the [Example](https://luolingchun.github.io/star-openapi/v0.x/Example/).
```python
import uvicorn
from pydantic import BaseModel
from starlette.responses import JSONResponse
from star_openapi import OpenAPI
info = {"title": "Star API", "version": "1.0.0"}
app = OpenAPI(info=info)
book_tag = {"name": "book", "description": "book tag"}
class BookModel(BaseModel):
name: str
age: int
@app.post("/book", summary="get books", tags=[book_tag])
async def create_user(body: BookModel):
"""
get all books
"""
print(body.model_dump_json())
return JSONResponse({"message": "Hello World"})
if __name__ == "__main__":
print(app.routes)
uvicorn.run(app)
```
## API Document
Run the [simple example](https://github.com/luolingchun/star-openapi/blob/main/examples/simple_demo.py), and go
to http://127.0.0.1:8000/openapi.
> OpenAPI UI plugins are optional dependencies that require manual installation.
>
> `pip install -U star-openapi[swagger,redoc,rapidoc,rapipdf,scalar,elements]`
>
> More optional ui templates goto the document
> about [UI_Templates](https://luolingchun.github.io/star-openapi/v0.x/Usage/UI_Templates/).
