-
Notifications
You must be signed in to change notification settings - Fork 302
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
Conversation
6431f19
to
2fafced
Compare
362f6cf
to
3fd8b55
Compare
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. |
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. |
Actually, there's quite a few tests with |
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. |
Are you updating this to RC3? I found that the Let me know if you're not in the middle of fixing it and I can have a stab at it. |
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 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.
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.
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.