Is your feature request related to a problem? Please describe.
The FIWARE service paths endpoint returns alot of extra fields besides the actual paths. In particular, for each path p there's a children field that contains the whole service path tree starting from the last node of p. Perhaps this is more than clients actually need. (Also, the root path will already contain the whole tree anyway.) We could return just root-to-leaf paths without including children fields.
Note. Under the bonnet service paths are represented with a class (ServicePath) that's a tree-like structure to encode the concept of FIWARE entity hierarchy where each node holds the name of a path component.
Describe the solution you'd like
Change the returned data format from (using simplified YAML representation instead of actual JSON)
Keep the current format and document the meaning of the children fields.
Additional context
For the record, here's the algo we designed in yesterday's session to do the job. We specified it directly in Haskell because Haskell lets you easily express maths ideas in code. Copy-paste into an online compiler, e.g.
-- canonical recursive tree structure
data Tree = N Int [Tree]
-- path type alias for clarity (a path is a sequence of nodes)
type Path = [Int]
-- example tree
t = N 1
[ N 2 [N 3 [], N 4 []]
, N 5
[ N 6 [N 7 [], N 8 []]
, N 9 []
]
]
-- extract root-to-leaf paths
paths :: Tree -> [Path]
paths (N v []) = [[v]]
paths (N v ts) = map (v:) (concatMap paths ts)
-- print t's root-to-leaf paths
result = paths t
main = mapM_ (putStrLn . show) $ result
If you run it, you'll see this output
[1,2,3]
[1,2,4]
[1,5,6,7]
[1,5,6,8]
[1,5,9]
As expected, since the program actually embodies a "proof of correctness".
Keep in mind that as @Cerfoglg pointed out, this isn't really an issue when retrieving service paths individually since there's only one children field in that case and nodes won't be repeated. See also: #221.
Is your feature request related to a problem? Please describe.
The FIWARE service paths endpoint returns alot of extra fields besides the actual paths. In particular, for each path
p
there's achildren
field that contains the whole service path tree starting from the last node ofp
. Perhaps this is more than clients actually need. (Also, the root path will already contain the whole tree anyway.) We could return just root-to-leaf paths without includingchildren
fields.Note. Under the bonnet service paths are represented with a class (
ServicePath
) that's a tree-like structure to encode the concept of FIWARE entity hierarchy where each node holds the name of a path component.Describe the solution you'd like
Change the returned data format from (using simplified YAML representation instead of actual JSON)
to something simpler e.g. just list root-to-leaf paths and their IDs
Describe alternatives you've considered
Keep the current format and document the meaning of the
children
fields.Additional context
For the record, here's the algo we designed in yesterday's session to do the job. We specified it directly in Haskell because Haskell lets you easily express maths ideas in code. Copy-paste into an online compiler, e.g.
If you run it, you'll see this output
As expected, since the program actually embodies a "proof of correctness".