All Projects → so1n → pait

so1n / pait

Licence: Apache-2.0 license
Python Modern API Tools, fast to code

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to pait

spectree
API spec validator and OpenAPI document generator for Python web frameworks.
Stars: ✭ 190 (+691.67%)
Mutual labels:  redoc, starlette, pydantic
starlite
Light, Flexible and Extensible ASGI API framework
Stars: ✭ 1,525 (+6254.17%)
Mutual labels:  redoc, starlette, pydantic
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+164850%)
Mutual labels:  redoc, starlette, pydantic
Swagger Py Codegen
a Python web framework generator supports Flask, Tornado, Falcon, Sanic
Stars: ✭ 508 (+2016.67%)
Mutual labels:  sanic, tornado
mongox
Familiar async Python MongoDB ODM
Stars: ✭ 113 (+370.83%)
Mutual labels:  starlette, pydantic
morelia server
Server for MoreliaTalk network
Stars: ✭ 25 (+4.17%)
Mutual labels:  starlette, pydantic
sticker
Sticker is a powerful yet boilerplate-free alternative to writing your web API.
Stars: ✭ 26 (+8.33%)
Mutual labels:  sanic, tornado
asymmetric
Ridiculously fast and easy module-to-API transformations. Learn in minutes, implement in seconds. Batteries included.
Stars: ✭ 35 (+45.83%)
Mutual labels:  redoc, starlette
prisma-client-py
Prisma Client Python is an auto-generated and fully type-safe database client designed for ease of use
Stars: ✭ 739 (+2979.17%)
Mutual labels:  type-hints, pydantic
aiodogstatsd
An asyncio-based client for sending metrics to StatsD with support of DogStatsD extension
Stars: ✭ 26 (+8.33%)
Mutual labels:  sanic, starlette
python-paginate
Pagination support for python web frameworks (study from will_paginate).
Stars: ✭ 17 (-29.17%)
Mutual labels:  sanic, tornado
Graphql Server
This is the core package for using GraphQL in a custom server easily
Stars: ✭ 65 (+170.83%)
Mutual labels:  sanic
Microservices Connector
Inter-Service communication framework, support for microservice architecture and distributed system
Stars: ✭ 17 (-29.17%)
Mutual labels:  sanic
Memegen
The free and open source API to generate memes.
Stars: ✭ 648 (+2600%)
Mutual labels:  sanic
Owllook
owllook-小说搜索引擎
Stars: ✭ 2,163 (+8912.5%)
Mutual labels:  sanic
Sanic Prometheus
Prometheus metrics for Sanic, an async python web server
Stars: ✭ 63 (+162.5%)
Mutual labels:  sanic
Lyanna
My Blog Using Sanic
Stars: ✭ 482 (+1908.33%)
Mutual labels:  sanic
Mangum
AWS Lambda & API Gateway support for ASGI
Stars: ✭ 475 (+1879.17%)
Mutual labels:  sanic
Sanic Openapi
Easily document your Sanic API with a UI
Stars: ✭ 447 (+1762.5%)
Mutual labels:  sanic
Sanic Jwt
Authentication, JWT, and permission scoping for Sanic
Stars: ✭ 189 (+687.5%)
Mutual labels:  sanic

Python Modern API Tools, fast to code

Coverage

PyPI - Python Version PyPI

GitHub Workflow Status GitHub release (release name instead of tag name) Test

Support framework


Documentation: https://so1n.me/pait/

中文文档: https://so1n.me/pait-zh-doc/


pait

Pait is an api tool that can be used in any python web framework (currently only flask, starlette, sanic, tornado are supported, other frameworks will be supported once Pait is stable).

Note:

mypy check 100%

test coverage 95%+ (exclude api_doc)

python version >= 3.7 (support postponed annotations)

The following code does not specify, all default to use the starlette framework.

Warning

There are changes between the current version and the 0.8 version of the API, For more information, please refer to 0.9.0version change

Feature

  • Parameter checksum automatic conversion (parameter check depends on Pydantic)
  • Parameter dependency verification
  • Automatically generate openapi files
  • Swagger, Redoc route
  • gRPC Gateway route
  • TestClient support, support response result verification
  • Support for plugin extensions, such as the Mock plugin

Installation

pip install pait

Simple Example

from typing import Type
import uvicorn  # type: ignore
from starlette.applications import Starlette
from starlette.responses import JSONResponse
from starlette.routing import Route

from pait.app.starlette import pait, add_doc_route
from pait.field import Body
from pait.model.response import PaitResponseModel
from pydantic import BaseModel, Field


class DemoResponseModel(PaitResponseModel):
    class ResponseModel(BaseModel):
        uid: int = Field()
        user_name: str = Field()

    description: str = "demo response"
    response_data: Type[BaseModel] = ResponseModel


@pait(response_model_list=[DemoResponseModel])
async def demo_post(
    uid: int = Body.i(description="user id", gt=10, lt=1000),
    user_name: str = Body.i(description="user name", min_length=2, max_length=4)
) -> JSONResponse:
    return JSONResponse({'uid': uid, 'user_name': user_name})


app = Starlette(routes=[Route('/api', demo_post, methods=['POST'])])
add_doc_route(app)
uvicorn.run(app)

How to used in other web framework?

If the web framework is not supported, which you are using.

Can be modified sync web framework according to pait.app.flask

Can be modified async web framework according to pait.app.starlette

IDE Support

While pydantic will work well with any IDE out of the box.

Full example

For more complete examples, please refer to example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].