yahoo / elide

Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.

Home Page:https://elide.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenAPIBuilder removes paths for relationships that are 3 levels deep. (7.0.0pr5)

bladedancer opened this issue · comments

commented

I have a simple graph a->b->c
When I enable the OAS generation the generated spec is including models for a, b & c but only APIs for a & b.

The problem is the pruning of duplicates:
https://github.com/yahoo/elide/blob/7.0.0-pr5/elide-swagger/src/main/java/com/yahoo/elide/swagger/OpenApiBuilder.java#L773

I'm not sure I understand what duplicates it's pruning but the logic seems to be grouping the paths by root type (a), then iterating over them looking for the shorter path. The paths are:

  1. a/{aId}/b/{bId}
  2. a/{aId}/b/{bId}/c/{cId}
  3. a/{aId}

(this is the order I see)

So on the first pass through path is a/{aId}/b/{bId} and nothing gets added to toRemove (because the only path shorter than it has no lineage).

Second time through is a different story:
path is a/{aId}/b/{bId}/c/{cId}
compare is a/{aId}/b/{bId}

compare.lineage.isEmpty() is false
path == compare is false

compare.shorterThan(path) is true ... so it removes a/{aId}/b/{bId}/c/{cId}......meaning there are no APIs generated for c in the spec.

Not sure I understand what's being attempted by this loop but something definitely looks wrong.


After sleeping on it - is the goal to find the shortest path through the graph to that node? At the moment it's just finding the shortest path, as well has checking if the path is shorter it should be checking if the final nodes in the path are the same, right?


Create a PR with the proposed fix:
#3024