https://github.com/ESSS/flask-restalchemy
Flask extension to build REST APIs based on SQLAlchemy models
https://github.com/ESSS/flask-restalchemy
flask-extension hacktoberfest sqlalchemy
Last synced: 10 months ago
JSON representation
Flask extension to build REST APIs based on SQLAlchemy models
- Host: GitHub
- URL: https://github.com/ESSS/flask-restalchemy
- Owner: ESSS
- License: mit
- Created: 2018-01-21T13:03:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-25T14:31:04.000Z (about 2 years ago)
- Last Synced: 2024-04-25T15:42:20.945Z (about 2 years ago)
- Topics: flask-extension, hacktoberfest, sqlalchemy
- Language: Python
- Homepage: http://flask-restalchemy.readthedocs.io
- Size: 244 KB
- Stars: 36
- Watchers: 16
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.rst
- License: LICENSE
Awesome Lists containing this project
README
# Flask-RESTAlchemy #
[](https://github.com/ESSS/serialchemy/actions)
[](https://codecov.io/gh/ESSS/flask-restalchemy)
[](https://github.com/psf/black)
[](https://flask-restalchemy.readthedocs.io/en/latest)
A Flask extension to build REST APIs. It dismiss the need of building *Schema* classes,
since usually all the information needed to serialize an SQLAlchemy instance is in the model
itself.
By adding a model to the API, all its properties will be exposed:
```python
class User(Base):
__tablename__ = "User"
id = Column(Integer, primary_key=True)
firstname = Column(String)
lastname = Column(String)
email = Column(String)
password = Column(String)
api = Api(flask_app)
api.add_model(User, "/user")
```
To change the way properties are serialized, declare only the one that needs a non-default
behaviour:
```python
from serialchemy import ModelSerializer, Field
class UserSerializer(ModelSerializer):
password = Field(load_only=True)
api = Api(flask_app)
api.add_model(User, "/user", serializer_class=UserSerializer)
```
### Release
A reminder for the maintainers on how to make a new release.
Note that the VERSION should folow the semantic versioning as X.Y.Z
Ex.: v1.0.5
1. Create a ``release-VERSION`` branch from ``upstream/master``.
2. Update ``CHANGELOG.rst``.
3. Push a branch with the changes.
4. Once all builds pass, push a ``VERSION`` tag to ``upstream``.
5. Merge the PR.
[Changelog]: https://regro.github.io/rever-docs/devguide.html#changelog