Closed (fixed)
Project:
OpenAPI
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
7 May 2019 at 21:10 UTC
Updated:
22 Jul 2019 at 14:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
e0ipsoProposed patch.
Comment #3
e0ipsoComment #4
e0ipsoSome extra fixes. I updated the IS.
Comment #5
e0ipsoSome more extra fixes. I updated the IS again.
Comment #6
e0ipsoThis is the final result after all the iterations. I'll be using this patch in the Contenta CMS. I could also implement this as a plugin in Contenta CMS if you think it's more appropriate, but I thought to contribute back.
Thanks!
Comment #7
e0ipsoSorry for the duplicate patch. This is the correct one.
Comment #8
e0ipsoComment #10
richgerdesThe current patch looks like an improvement, but it appears the patch drops schema for the relationship routes. For example, the
/taxonomy_term/bundle/{entity}/parentand/taxonomy_term/bundle/{entity}/relationships/parentroutes have been removed are not being generated by the expectations doc. As a result, this patch still needs some work, before we can merge it.It looks like this is the result of the below change.
Previous to this patch, the logic only skipped non jsonapi routes, it now skips all routes which aren't root entity level routes. Is there a reason why these routes were removed here? Is there additional logic which is required to build these routes to have them added back into the doc? I am less familiar with how this is supposed to work, and it would be faster if someone else took a stab at fixing it. To generate expectations locally, set
const GENERATE_EXPECTATION_FILES = true;inRequestTest. Then run the test library. I'm happy to worry about doing this if the test failures can be reduced to eliminating following formatted lines or to have a new generic route added.- /taxonomy_term/taxonomy_term_test/{entity}/relationships/parent' => Array (...)Comment #11
richgerdesForgot to include patch with updated expectations.
Even if the above patch passes, this still not finished pending resolution of the issue noted in #10.
Comment #12
e0ipsoThose routes were removed for several reasons:
tagsdocumentation under article->tags but also under the Tags resource.The only missing information that is missing is the fact that there is a route there. I think that is less relevant because it's explained in the documentation and made explicit by the
relatedandrelationshiplinks in the responses. Since there is no clear solution to document that without the clutter I'll argue that we should merge this and address that in a follow up issue.Comment #13
richgerdesI think you have a valid point, however that's not OpenAPI's objective. The spec is designed and intended to be able to generate a fully working api client, so knowledge of the sup routes is critical. To put it simply, OpenAPI docs doesm't care about the Json:API spec or documentation what so ever and can't assume the user does either.
So yes, your points are valid for the purposes of ReDoc and Swagger, but are against the objectives of OpenAPI spec.
That still doesn't mean we can't build a ui and mechanisms to filter the redoc/swagger uis to limit the data which is returned and displayed in the UIs, and this is what I would suggest as the correct way to implement this as opposed simply removing them. There isn't a spec that I am aware of to implement this, but we currently already have a format for filtering the results by entity type and bundle.
There are already a few open issues for addressing the concerns which you bring up about extra/redundant data cluttering the UIs
Comment #14
e0ipso@richgerdes what is the next step? Should we commit the patch without that part then I can write a patch so I can use it in Contenta CMS?
Comment #15
richgerdesI think the next step here is to update the patch with one that add the features that were previously missing, and doesn't remove anything.
I don't think Contenta should probably not be patching OpenAPI to alter its functionality, since if this is highly error prone when OpenAPI makes a new release. I think the best path forward is to implement a system of filters, which can be defined by a given generator, and then exposed on the ReDoc and swagger pages, so the user can filter the results to what's relevant. Content can then use a hook alter or another mechanism to default the filters to the limited view.
OpenAPI already supports the passing of the
optionsurl parameter to the generator. Currently the available options are only used to control the entity types which are included in the generated doc. This parameter could be used to implement the same functionality for route types and methods as well. Maybe also filtering by tag could be helpful.Right now there is no api to determine the available filters, so this would be necessary in order to move forward with building a ui to set the filters in ReDoc and Swagger. I may have time to work on this later this week, but no promises. My only thought this far is to have a "getAvailableOption" function on
OpenApiGeneratorBasewhich then can be extended byJsonApiGenerator, to define the relevant filters. I hadn't thought much what kind of data would be returned here. Possibly Data Definitions or JsonSchema. I'm open to recommendations.My main question for you is to determine what the desired options/filters would be for the jsonapi routes, so that we can start moving this forward.
Thoughts?
Comment #16
e0ipsoWhile I agree with you on the best course of action, since very little of the outlined solution is ready, Contenta will need to be patched until all of the APIs and features are available.
Do you see any other workaround?
Comment #17
richgerdesI'm can try and focus on the implementation, if you can give me an idea of what you would be expecting to be able to do with it?
With the current api, the
$optionsvariable is already exposed, so you can implement the filter code as is. There just isn't a pretty way to display the filter fields in the redoc/swagger ui at the moment. Though, once the filter logic is added, which could be done in your patch, then there is no reason contenta couldn't then alter the redoc page to specify the options that you are looking forComment #18
e0ipsoSadly I don't have available cycles to implement this 😔
Comment #19
richgerdesI know that feeling all too well. No pressure there. Since you understand what's going on with the current patch better then I, if are able to find the time to get this patch to a point where it no longer removes information, I can will commit it and work on adding the described filtering functionality later this week.
Comment #20
e0ipsoI got convinced about leaving the related and relationship resources in the spec document. However the generated docs were widely inaccurate and with a confusing naming scheme. This patch should address that.
Comment #21
richgerdesThis patch is massive and looks like it reverts a large number of changes to the current HEAD. This includes changes to link names, routes, and other side effects which I don't believe were intentional or relevant to the module. Can you please verify that the patch applies to the lastest head with only the intended changes?
Comment #22
e0ipsoMerged the changes from
8.x-1.x. Luckily it was mostly my changes so I could fix the merge conflicts. This is the list of commits from the patch in #7:Comment #24
richgerdesThe patch looks good. I've committed it to dev.
Comment #25
richgerdes