-
Notifications
You must be signed in to change notification settings - Fork 7
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
filter query parameters of old AiiDA REST API incompatible with OpenAPI/fastapi standard #16
Comments
One way around it could be to introduce a
It seems to me that this should work in principle, as the openapi standard states
However, looking at the string that is fed into
This means applying This seems incorrect to me, as the docs of parse_qsl explicitly state:
I wonder whether there is a way to let the encoded values arrive there... traceback
Ok, I see that at
the query parameter is actually still percent-encoded.
[1] The quotation marks are actually already encoded when I just copy the URL from the URL field of the web browser into this text box, so perhaps that happens on the browser level. |
Oh yeh indeed, its a bit of a pain to use as a "client", you can see here where I have to do "partial" encoding to get it to work: So yeh, in terms of not breaking too much from the existing API, I can see why we want to implement this filter parameter, but... from a top-level / client perspective, I feel I would just generally avoid it, and use instead the "more structured" querybuilder/graphql endpoint |
I just discovered that fastapi has built-in support for parsing the starlette request object manually: https://fastapi.tiangolo.com/advanced/using-request-directly/ If I understand correctly, one can even still have automatic parsing & docs for all of the fields that follow the |
Interesting cheers, although... it sounds like that removes a lot of the features of fastapi |
If I understand correctly, then this is a limitation of the OpenAPI standard: query parameters can only have a value, there is no concept of different relations (smaller than, ...) between query parameters and their value other than equality; i.e. there is nothing This would mean that the filter parameters would be missing e.g. from the interactive client built into the docs; on the other hand it would potentially allow us to be fully backward compatible, which is worth something. |
Well it would not just be the filter parameters, it would be every parameter, wouldn't it? |
On a high-level note, it would be good to have an idea of who is already using the REST API, and so who this would affect (just Mat Cloud or lots of others). It does clearly state when you start it presently that it should not be used for production use, but then it also has been around for many years. |
I don't think so - as mentioned in the page I linked, you can simply declare any of the parameters that use the
That is a good point. So far I know of
There may be a little more, and we should ask around in a few days once we have a clearer idea of what we could realistically do. I do suspect that the migration of the aiida-explorer would be the largest task.
Well, that is just for the server that ships with |
well I will leave you to figure that out for now, because yeh, from a selfish viewpoint, if I can get the graphql working nicely, I will just look to switch to that for all client-side querying 😝 |
It seems that, in general, the exact structure of the query string is not standardized.
For example, RFC3986 only mentions that
Similar the latest RFC8820.
However, there is a W3C recommendation for encoding form data (
application/x-www-form-urlencoded
):While the OpenAPI standard is not explicit on the name-value separator, all of the examples in the spec use
=
.As pointed out by @chrisjsewell,
fastapi
relies onstarlette
which internally relies onurllib
'sparse_qsl
function for parsing the query parameters.parse_qsl
(part of the python standard library) also hardcodes the=
separator.This clashes with the filter operators from the aiida-core rest api, which allow e.g. for queries like
The text was updated successfully, but these errors were encountered: