Skip to content
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

Produce APIs that comply with the (provisional) JSON API standard. #404

Merged
merged 106 commits into from
Jan 29, 2016

Conversation

jfinkels
Copy link
Owner

This will be a major change to the behavior of Flask-Restless, so it should be postponed until, say a 1.0.0 release. The first commit I've added below adds failing tests for the behavior expected by the JSON API standard.

Further work on this branch will fix many of the issues with discoverability, performance, and unexpected behavior reported in other issues.

@jfinkels jfinkels force-pushed the jsonapi branch 3 times, most recently from 6431f19 to 2fafced Compare February 24, 2015 07:23
@jfinkels jfinkels force-pushed the jsonapi branch 4 times, most recently from 362f6cf to 3fd8b55 Compare March 8, 2015 00:09
@ctolsen
Copy link

ctolsen commented Mar 20, 2015

I'm new to Flask-Restless, and don't know it well enough yet, but this is some amazing work. I was reading the documentation for some research a while ago, and JSONAPI support was one of the things I expected to have to hack together myself. The rest is exactly what I was looking for.

If the long term goal is to get this merged back in, I would like to offer some help improving and maintaining this in a branch until then.

@jfinkels
Copy link
Owner Author

Hi @ctolsen! As you can see on this branch, I'm essentially in the middle of rewriting everything, since I'm older and wiser today than when I started this project. In the process of creating JSON API support, I'm rewriting all the code and tests right now (haven't even started on documentation!), so I don't think you can help with this branch quite yet. But if you see something that's wrong, feel free to let me know or fix it. I'll be working on this branch for a while still.

@jfinkels
Copy link
Owner Author

Actually, there's quite a few tests with assert False, 'Not implemented', which means I was either too lazy to write a test or too confused to figure out an appropriate test. I would be grateful if someone implemented some of those.

@ctolsen
Copy link

ctolsen commented Mar 25, 2015

I'm slowly getting up to speed with the framework in general, so I'll certainly have a look at that once I have my head wrapped around everything a bit better.

@ctolsen
Copy link

ctolsen commented Apr 3, 2015

Are you updating this to RC3? I found that the linkage attribute isn't fully supported for one-to-many's.

Let me know if you're not in the middle of fixing it and I can have a stab at it.

@jfinkels
Copy link
Owner Author

jfinkels commented Apr 3, 2015

Yes, I am working off the most recent version of the JSON-API specification. If you see some place where something is not fully tested, please do add the missing test method and make a pull request (with respect to this jsonapi branch). Even better, make a pull request that implements the changes to the code that make the test pass.

Where I really need help is with association proxies and/or many-to-many relationships. There's a bunch of places where there are unimplemented tests, and I simply don't know how to implement them!

Previously, the behavior of Flask-Restless was a bit arbitrary. Now we
force it to comply with a concrete (though still changing)
specification, which can be found at http://jsonapi.org/.

This is a (severely) backwards-incompatible change, as it changes which
API endpoints are exposed and the format of requests and responses.

This change also moves JSON API compliance tests to a convenient
distinct test module, `tests.test_jsonapi.py`, so that compliance with
the specification can be easily verified. These tests correspond to
version 1.0rc3 of the JSON API specification, which can be found in
commit json-api/json-api@a75f88d.

This change fixes (or at least makes it much easier to fix or much
easier to mark as "won't fix") quite a few issues.
jfinkels and others added 25 commits December 28, 2015 17:19
All global parameters are passed to the APIManager constructor.

The init_app method now accepts only one argument: the app instance.

If the app instance is not supplied to the constructor, the create_api method must be called *before* calling init_app, since init_app will register the blueprints created by create_api. If the constructor is supplied with an app instance, this tells the extension that the user is not interested in using multiple applications (as per Flask specs), the app instance is stored and create_api can be used any time after APIManager has been instantiated.

Creating blueprints using create_api_blueprint now requires a mandatory name argument.
Blueprint names are generated using uuid1 by create_api method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants