Skip to content

use app.json_encoder #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 5, 2017
Merged

use app.json_encoder #84

merged 2 commits into from
Oct 5, 2017

Conversation

winstonf88
Copy link
Contributor

@winstonf88 winstonf88 commented Oct 5, 2017

The flask-api JSONRenderer class is ignoring custom JsonEncoder and directly using the default class provided by flask, it should use the applications json_encoder atribute.
Example:
http://flask.pocoo.org/snippets/119/

@jacebrowning
Copy link
Member

@winstonf88 I like the idea behind this change. The test failure seem legitimate. Does this line need to be wrapped in an application context? Or is there some other way to pass in the current application?

@winstonf88
Copy link
Contributor Author

winstonf88 commented Oct 5, 2017

I added the app context inside tests, I believe there is no other way. @jacebrowning

date = datetime(2017, 10, 5, 15, 22)
with app.app_context():
content = renderer.render(date, MediaType('application/json'))
self.assertEqual(content, '"{}"'.format(date.isoformat()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good test!

@jacebrowning jacebrowning merged commit 76cb93a into flask-api:develop Oct 5, 2017
@jacebrowning
Copy link
Member

Release in Flask-API==1.1b1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants