python-swagger-restful-api
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.8+ based on standard Python type hints.
The key features are:
- Fast: Very high performance, on par with NodeJS and Go (thanks to Starlette and Pydantic). One of the fastest Python frameworks available.
- Fast to code: Increase the speed to develop features by about 200% to 300%. *
- Fewer bugs: Reduce about 40% of human (developer) induced errors. *
- Intuitive: Great editor support. Completion everywhere. Less time debugging.
- Easy: Designed to be easy to use and learn. Less time reading docs.
- Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
- Robust: Get production-ready code. With automatic interactive documentation.
- Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
https://python-poetry.org/docs/?ref=dylancastillo.co#installing-with-the-official-installer
python -m venv .venv
source .venv/bin/activate
Using Poetry: Create the virtual environment in the same directory as the project and install the dependencies:
poetry config virtualenvs.in-project true
poetry init
poetry add fastapi
poetry add uvicorn
poetry add pytz
poetry add httpx
poetry add pytest
poetry add pytest-cov
poetry add requests
poetry add pyyaml
poetry add elasticsearch==7.13
poetry add python-dotenv
- Go to virtual enviroment using
source .venv/bin/activate
- Run this command manually:
poetry run py.test -v --junitxml=test-reports/junit/pytest.xml --cov-report html --cov tests/
or./pytest.sh
platform win32 -- Python 3.11.7, pytest-8.1.1, pluggy-1.4.0 -- C:\Users\euiyoung.hwang\Git_Workspace\python-swagger-restful-api\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\euiyoung.hwang\Git_Workspace\python-swagger-restful-api\tests
configfile: pytest.ini
plugins: anyio-4.3.0, cov-5.0.0
collected 3 items
- CircleCI (
./circleci/config.yml
): CircleCI is a continuous integration and continuous delivery platform that helps software teams work smarter, faster. With CircleCI, every commit kicks off a new job in our platform, and code is built, tested, and deployed. - Github Actions (
./.github/workflows/build-and-test.yml
) : GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository, or deploy merged pull requests to production.
- sudo service swagger_es_api status/stop/start/restart
#-- /etc/systemd/system/swagger_es_api.service
[Unit]
Description=Swagger ES Service
[Service]
User=devuser
Group=devuser
Type=simple
ExecStart=/bin/bash /home/devuser/Git_Repo/service-start.sh
ExecStop= /usr/bin/killall swagger_es_service
[Install]
WantedBy=default.target
# Service command
sudo systemctl daemon-reload
sudo systemctl start swagger_es_service.service
sudo systemctl status swagger_es_service.service
sudo systemctl stop swagger_es_service.service
sudo service swagger_es_service status/stop/start