So yes, we are nearly there, in fact we only have a few query options remaining, which I'll cover entirely here because they're all pretty miniscule.
Expand
Expand allows the expansion of a particular property path in OData, like so
Expand the path Products/Suppliers
/Categories?$expand=Products/Suppliers
Expand the path Suppliers AND expand the path Products
/Categories?$expand=Suppliers,Products
So this is quite easy, $expand expects a list of ResourcePath, separated by a comma.
I'll not show the tests for this, you can assume I have some though, with the appropriate data appearing on the model..
ExpandOption =
seq("$expand=")
listOf(`PropertyPath, ','):properties -> { name: "$expand", value: { properties: properties }}
,
Doesn't take a genius to work that one out does it :)
Format
This one is a doozy, the docs pretty much say it accepts
So what we're saying here is that we'll parse any content type, what I'll do is just parse the general pattern to make sure it doesn't contain garbage and leave it at that.
FormatOption =
seq("$format=")
ContentType:type -> { name: "$format", value: type }
,
ContentType =
< letter+
'/'
letter+
(
'+' letter+
)?
>
There are probably more rules than that but it's easily improved later
Select
Select tells us what is going to be brought back from a query, this can either be a property path, a collection of property paths or an asterisk.
An asterisk means bring back EVERYTHING. Nothing special.
SelectOption =
seq("$select=")
(
"*" -> '*'
| listOf(`PropertyPath, ','):properties -> { properties: properties }
):value -> { name: "$select", value: value }
,
Highlighting a problem or three
That's pretty much the entire spec sorted out, and we have a few tidy ups on our hand
I'll sort all these out in the next entry (I imagine that there will have been some comments made about these already in the future... in the past now, I wrote all this a month ago after all) and then we'll be finished and onto something new.
2020 © Rob Ashton. ALL Rights Reserved.