Comments (6)
Hi Ralf,
thanks for the fast and precise answer!
We are developing and using @balena/pinejs to auto-generate our OData API at balena.io. PineJs implements DELETE and Patch on filtered collections generically for every collection as it generates the end-points for each resource in the same way.
Thus, every instance of our open source published IoT fleet management tool https://github.com/balena-io/open-balena
and our balenaCloud API ( https://api.balena-cloud.com/ ) are supporting DELETE and PATCH on filtered collections.
The overall idea to use odata-openapi translator is to have it build into PineJS so that documentation renders, SDK generators and other tools can either use the OData CSDL or openapi spec to generate their outputs.
In particular the next goal are automatic updated openapi specs for documenetation, provided by PineJS directly.
I'll keep it on a watch and in the meantime I'll figure out how to add it to the openapi spec, I'm thinking of copy/pasta the block from the single entity documentation.
Thanks a lot again, best regards and have a good start into 2023
Harald
from odata-openapi.
Hi Harald,
Thanks for the info, and cool that you are building APIs with this feature.
I'll put support for FilterSegmentSupported
into the backlog.
from odata-openapi.
Hi Harald,
Happy New Year!
PATCH and DELETE requests to filtered collections of entities aren't yet supported by the generator because I don't know of any OData services that support this advanced feature.
It could be added for services that advertise this feature via the FilterSegmentSupported
property of UpdateRestrictions
and DeleteRestrictions
annotations.
I'll keep this issue open as a reminder.
If you know of services providing this feature, please tell me.
Thanks in advance
Ralf
from odata-openapi.
Hi Harald,
Could you please check whether https://petstore.swagger.io/?url=https://raw.githubusercontent.com/oasis-tcs/odata-openapi/a91398b3bbb24fb49054af7e275e6a673981a60c/examples/annotations.openapi3.json#/ matches your expectation?
The example shows /$filter(...)
segments on a root entity set and on a collection-valued navigation property, each with DELETE
and PATCH
.
Thanks in advance
from odata-openapi.
Hi Ralf,
big thanks for the responsiveness and sending over an example to review!
The provided openapi spec looks exactly as the OData V4 core spec, so I think it's as expected.
We internally discussed it and unfortunately, our filtered collection actions for Delete and Patch follow the old V3 implementation:
DELETE /AllSet?$filter = {filter_expression}
PATCH /AllSet?$filter = {filter_expression}
How we will approach this now is:
- We will use these correctly documented V4 filtered collection endpoints and blatanty hack them to represent our old way :)
- Then we start with finding the gaps between our implementation, which is mostly V3 compatible, and OData V4 / V4.01.
- We aim for compatibility with OData V4.
One completely just curious question during our internal discussion was, why the filteredCollection PATCH and DELETE are ended with a $each
. This feels redundant and from our understanding doesn't represent the otherwise full and unambiguous expressiveness of OData.
Thanks for your friendly and open support!
Harald
from odata-openapi.
Hi Harald,
Assume we have a bound function foo
with two overloads, one bound to a single thingy, and one bound to a collection of thingies.
This leads to the following request patterns
Request | Meaning |
---|---|
GET /thingies/foo() |
call the collection-bound overload on all thingies |
GET /thingies/42/foo() |
call the single-bound overload on the thingy with key 42 |
GET /thingies/$filter(color eq 'red')/foo() |
call the collection-bound overload on all red thingies |
GET /thingies/$filter(color eq 'red')/$each/foo() |
call the single-bound overload on each single red thingy |
The request with the URL ending in /$each
is kind of an iterator over the filtered collection and allows us to decide which overload to call.
We have the same ambiguity with PATCH
because we allow update requests to collections now, sending a delta payload as the request body.
Request | Meaning |
---|---|
PATCH /thingies |
update the collection of all thingies with the provided delta request body |
PATCH /thingies/$each |
update each thingy with the provided single-update request body |
And we use the same pattern for DELETE
requests although we haven't yet specified a meaning for DELETE /thingies
.
The function call example also shows why we added the filter in the path. If the collection-bound overload returns a collection, there are two collections to filter: the input and the output of the function.
Having the filter query option always filter the output of an operation simplifies things.
Hope this explains how we arrived at the current URL syntax.
Ralf
from odata-openapi.
Related Issues (20)
- Specific OData XML file cannot be converted, only .tmp file is created HOT 2
- Error: spawnSync java ENOENT HOT 3
- Unexpected Token Error HOT 3
- Edm.Int64 PrimitiveType translated to anyOf["string", "integer"] HOT 2
- Support for /$count operation HOT 4
- SAP R3 FunctionImport: Documentation Tag in Parameter fails the generation HOT 4
- Property sap:label is not handled HOT 2
- <Key> in Schema creates errors HOT 1
- Empty output while converting `https://graph.microsoft.com/beta/$metadata` HOT 6
- FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory HOT 5
- More than two annotation target path segments HOT 5
- Unexpected node HOT 4
- Error in Conversion .edmx to OpenAPI format HOT 1
- documentation item HOT 2
- Could it be possible to generate for a part of the odataModel ? HOT 31
- Support annotation Core.ComputedDefaultValue
- TypeError: model.element(...).find is not a function HOT 4
- Missing cli feature: Add $metadata operation and root HOT 4
- Covert XMl to open api failes HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata-openapi.