Skip to content
项目

0xTheProDev/fastapi-clean-example

在 GitHub 查看

关于

使用 FastAPI 框架实现的整洁架构示例。

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

fastapi-clean-example

Python FastAPI OpenAPI Swagger GraphQL Code style: black Typed with: pydantic Open Issues Closed Issues Open Pulls Closed Pulls Contributors Activity

Description

Example Application Interface using FastAPI framework in Python 3

This example showcases Repository Pattern in Hexagonal Architecture (also known as Clean Architecture). Here we have two Entities - Books and Authors, whose relationships have been exploited to create CRUD endpoint in REST under OpenAPI standard.

Installation

  • Install all the project dependency using Pipenv:

    $ pipenv install --dev
    
  • Run the application from command prompt:

    $ pipenv run uvicorn main:app --reload
    
  • You can also open a shell inside virtual environment:

    $ pipenv shell
    
  • Open localhost:8000/docs for API Documentation

  • Open localhost:8000/graphql for GraphQL Documentation

Note: In case you are not able to access pipenv from you PATH locations, replace all instances of pipenv with python3 -m pipenv.

Testing

For Testing, unittest module is used for Test Suite and Assertion, whereas pytest is being used for Test Runner and Coverage Reporter.

  • Run the following command to initiate test:
    $ pipenv run pytest
    
  • To include Coverage Reporting as well:
    $ pipenv run pytest --cov-report xml --cov .
    

License

© MIT License

探索相关项目

加载中…