A simple async API framework based on Starlette.
Project description
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
-
Interactive OpenAPI documentation: Swagger, Redoc, RapiDoc, RapiPdf, Scalar, Elements
-
Data validation: Fast data verification based on Pydantic
-
Websocket: Support for websocket
Requirements
Python 3.11+
star-openapi is dependent on the following libraries:
Installation
pip install -U star-openapi[swagger]
Optional dependencies
httpx- Required if you want to use theTestClient.python-multipart- Required if you want to support form parsing, withrequest.form().itsdangerous- Required forSessionMiddlewaresupport.pyyaml- Required forSchemaGeneratorsupport.
You can install all of these with pip install star-openapi[full].
- 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.
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, 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file star_openapi-0.9.4.tar.gz.
File metadata
- Download URL: star_openapi-0.9.4.tar.gz
- Upload date:
- Size: 552.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b32fa1e8ecced4b3893b4ec8c9a418f6a0f4759cc1d4be87536cf16907275973
|
|
| MD5 |
377c56196200ccf01eadef035edd2da4
|
|
| BLAKE2b-256 |
26575a6b7f3cdd3feab01a317c7104bd97ded5d334d474ec806e7b06793e4a61
|
File details
Details for the file star_openapi-0.9.4-py3-none-any.whl.
File metadata
- Download URL: star_openapi-0.9.4-py3-none-any.whl
- Upload date:
- Size: 41.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4822044a42797f5fe3e8cc9cb199f1f5652eb7b29cc59d2ac5abbe303e210eb
|
|
| MD5 |
a7710a7212c0ae796a1da37020d42e83
|
|
| BLAKE2b-256 |
56c4811e115d07f4a7986eb67ab6f6d53b0f6701c040fd9e8c30d6efb8b4eab7
|