Flask-RESTX-marshmallowยค
Flask-RESTX-marshmallow is a powerful extension that seamlessly combines Flask, Flask-RESTX, and Marshmallow to provide a robust foundation for building RESTful APIs with automatic documentation and data validation.
โจ Featuresยค
- ๐ Seamless Integration: Combines Flask-RESTX's API documentation with Marshmallow's powerful serialization
- ๐ Automatic Documentation: Generate interactive Swagger/OpenAPI documentation automatically
- ๐ Data Validation: Built-in request/response validation using Marshmallow schemas
- ๐ฏ Type Safety: Full type hint support for better development experience
- ๐ง Easy Configuration: Minimal setup required to get started
- ๐ฆ SQLAlchemy Integration: Works perfectly with Flask-SQLAlchemy
๐ง Requirementsยค
- Python 3.12+
- Flask 3.1+
- Flask-RESTX 1.3+
- Marshmallow 4.0+
๐ฆ Installationยค
Install the extension with pip:
pip install flask-restx-marshmallow
or with poetry:
poetry add flask-restx-marshmallow
or with uv
uv add flask-restx-marshmallow
๐ Quick Startยค
Complete Exampleยค
For a comprehensive example with SQLAlchemy integration, see app.py
. This example demonstrates:
- RESTful API endpoints with full CRUD operations
- Automatic request/response validation
- Interactive Swagger documentation
- Database integration with Flask-SQLAlchemy
- Error handling and status codes
The example application provides these endpoints:
Endpoint | Method | Description |
---|---|---|
/tasks/ |
GET | Query all tasks with optional filtering |
/tasks/ |
POST | Create a new task |
/tasks/<id> |
GET | Retrieve a specific task by ID |
/tasks/<id> |
PATCH | Update a task partially |
/tasks/<id> |
DELETE | Delete a task by ID |
๐โโ๏ธ Running the Exampleยค
-
Clone the repository:
git clone https://github.com/1746104160/flask-restx-marshmallow.git && cd flask-restx-marshmallow
-
Install dependencies:
orpoetry install --with dev
uv sync --dev
-
Run the example application:
orpython app.py
flask run
-
Visit
http://localhost:5000
to explore the interactive API documentation.
๐ Documentationยค
Visit the interactive API documentation when running your application to explore all available endpoints and schemas. The documentation is automatically generated from your code and provides:
- Interactive API testing: Try out endpoints directly from the browser
- Schema visualization: See request/response models with examples
- Parameter documentation: Understand required and optional parameters
- Error responses: Learn about possible error scenarios
๐งช Testingยค
Run the test suite:
pytest
๐ Licenseยค
This project is licensed under the MIT License.
๐ Linksยค
- GitHub Repository
- PyPI Package
- Flask Documentation
- Flask-RESTX Documentation
- Marshmallow Documentation
โญ Star Historyยค
If you find this project useful, please consider giving it a star on GitHub!