Giter VIP home page Giter VIP logo

fastapi-crudrouter's Introduction

⚡ Create CRUD routes with lighting speed
A dynamic FastAPI router that automatically creates CRUD routes for your models

Tests Downloads Package version License

PyPI - Python Version


Documentation: https://fastapi-crudrouter.awtkns.com

Source Code: https://github.com/awtkns/fastapi-crudrouter


Tired of rewriting generic CRUD routes? Need to rapidly prototype a feature for a presentation or a hackathon? Thankfully, fastapi-crudrouter has your back. As an extension to the APIRouter included with FastAPI, the FastAPI CRUDRouter will automatically generate and document your CRUD routes for you, all you have to do is pass your model and maybe your database connection.

FastAPI-CRUDRouter is lighting fast, well tested, and production ready.

Installation

pip install fastapi-crudrouter

Basic Usage

Below is a simple example of what the CRUDRouter can do. In just ten lines of code, you can generate all the crud routes you need for any model. A full list of the routes generated can be found here.

from pydantic import BaseModel
from fastapi import FastAPI
from fastapi_crudrouter import MemoryCRUDRouter as CRUDRouter

class Potato(BaseModel):
    id: int
    color: str
    mass: float

app = FastAPI()
app.include_router(CRUDRouter(schema=Potato))

Advanced Usage

fastapi-crudrouter provides a number of features that allow you to get the most out of your automatically generated CRUD routes. Listed below are some highlights.

  • Automatic Pagination (docs)
  • Ability to Provide Custom Create and Update Schemas (docs)
  • Dynamic Generation of Create and Update Schemas (docs)
  • Ability to Add, Customize, or Disable Specific Routes (docs)
  • Native Support for FastAPI Dependency Injection (docs)

Supported Backends / ORMs

fastapi-crudrouter currently supports a number of backends / ORMs. Listed below are the backends currently supported. This list will likely grow in future releases.

  • In Memory (docs)
  • SQLAlchemy (docs)
  • Databases (async) (docs)
  • Gino (async) (docs)
  • Ormar (async) (docs)
  • Tortoise ORM (async) (docs)

OpenAPI Support

By default, all routes generated by the CRUDRouter will be documented according to OpenAPI spec.

Below are the default routes created by the CRUDRouter shown in the generated OpenAPI documentation.

OpenAPI Route Overview

The CRUDRouter is able to dynamically generate detailed documentation based on the models given to it.

OpenAPI Route Detail

fastapi-crudrouter's People

Contributors

awtkns avatar dclimber avatar realitix avatar collerek avatar andreipopovici avatar sondrelg avatar turalpb avatar andrewthetechie avatar agallant avatar jaypalm avatar jm-moreau avatar dorskfr avatar archydeberker avatar nuno-andre avatar slamer59 avatar daxxog avatar joshrosenblum avatar sorxcode avatar 0x587 avatar

Stargazers

Denis avatar

Forkers

kranushealth

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.