Comments (10)
It seems to be the default and not the onupdate
, the code below does generate the swagger.json
class CreatedMixin:
created_at = db.Column(db.DateTime(timezone=True))
updated_at = db.Column(db.DateTime(timezone=True), onupdate=dt.utcnow)
from safrs.
Sorry for not answering earlier. I'll look into it.
I think this will work:
created_at = db.Column(db.DateTime(timezone=True), default=dt.utcnow())
but that's not what you want obv. Will sort it out asap.
from safrs.
No worries, how was your vacation?
from safrs.
lol, had a great time, that's why i couldn't reply indeed :)
from safrs.
ok, implemented a fix, can you check it works for you?
from safrs.
Sadly no...
from datetime import datetime as dt
# from flask_sqlalchemy import SQLAlchemy
from .extensions import db # db = SQLAlchemy()
class CreatedMixin:
created_at = db.Column(db.DateTime(timezone=True), default=dt.utcnow)
updated_at = db.Column(db.DateTime(timezone=True), default=dt.utcnow, onupdate=dt.utcnow)
[2019-03-26 21:15:24,933] db:589 DEBUG: Failed to get python type for column publisher.created_at
[2019-03-26 21:15:24,934] _api:427 ERROR: <lambda>() missing 1 required positional argument: 'ctx'
Traceback (most recent call last):
File "/home/patrick/PycharmProjects/ebookhub-backend/venv/src/safrs/safrs/_api.py", line 421, in api_decorator
decorated_method = swagger_decorator(decorated_method)
File "/home/patrick/PycharmProjects/ebookhub-backend/venv/src/safrs/safrs/swagger_doc.py", line 383, in swagger_doc_gen
sample = cls._s_sample_dict()
File "/home/patrick/PycharmProjects/ebookhub-backend/venv/src/safrs/safrs/db.py", line 592, in _s_sample_dict
arg = column.default.arg()
TypeError: <lambda>() missing 1 required positional argument: 'ctx'
from safrs.
Can you try now? The default arg is ignored now if it's callable.
I'll look at it again later, but callable defaults may cause more issues so I think it's better to just ignore them for now.
The _s_sample_dict
is used to generate a sample swagger payload. But when there's a column default, the default will be used so it's not really that important. and the swagger.json can be customized/extended anyway if needed.
from safrs.
The code does run now but throws a bunch of debug messages.
[2019-03-27 11:37:22,185] db:589 DEBUG: Failed to get python type for column publisher.created_at
[2019-03-27 11:37:22,186] db:589 DEBUG: Failed to get python type for column publisher.updated_at
[2019-03-27 11:37:22,251] db:589 DEBUG: Failed to get python type for column publisher.created_at
[2019-03-27 11:37:22,252] db:589 DEBUG: Failed to get python type for column publisher.updated_at
[2019-03-27 11:37:22,252] db:589 DEBUG: Failed to get python type for column publisher.created_at
[2019-03-27 11:37:22,253] db:589 DEBUG: Failed to get python type for column publisher.updated_at
from safrs.
This message should be gone now.
from safrs.
fixed in v2.1.0
from safrs.
Related Issues (20)
- Invalid swagger for "properties" under "definitions" breaks defintions display and validation HOT 7
- Patch method unreliable? HOT 2
- Read-only Columns HOT 2
- Flask-SQLAlchemy weakref KeyError
- in version 3.0 _s_count function does not apply filters to query HOT 1
- `count` property value is wrong for `GET` methods HOT 1
- Unable to delete entries HOT 5
- overriding methods does not work HOT 2
- extend API with custom classes HOT 1
- requirements.txt too restrictive HOT 1
- Duplicate definitions generated HOT 5
- safrs doesn't work in python 3.9 - TypeError HOT 4
- expose_existing starts but no swagger.json found HOT 1
- Run in example demo_relationship.py creating users or books in flask_admin returns Integrity Errors HOT 17
- Doubts about SAFRS HOT 2
- JSONAPI relationship missing in the swagger documentation HOT 4
- Swagger generation removing plurals HOT 1
- Flask 2.0 / Flask-restful "ImportError: cannot import name '_endpoint_from_view_func'" HOT 1
- Possible issue with BIGINT primary keys? HOT 5
- Make many to many relationship methods extendable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from safrs.