grape-swagger icon indicating copy to clipboard operation
grape-swagger copied to clipboard

intercept generated swagger doc for modification/extension

Open pswenson opened this issue 9 years ago • 7 comments

Often we will run into a swagger feature that isn't supported by the grape-swagger integration. So my question is, is there a way to intercept the generated swagger json documentation and modify/extend it?

Our specific problems is we have some magic rails(not grape) routes from doorkeeper in addition to standard grape routes that we want to document in swagger. So being able to intercept the generated swagger doc and generate json for these routes would solve the problem.

T

pswenson avatar Jun 07 '16 20:06 pswenson

sorry, this isn't possible ATM direct from the gem, but it sounds like a cool feature

LeFnord avatar Jun 07 '16 21:06 LeFnord

@pswenson … can you have a look on the rake task, if it is what you want … feedack and PRs welcome 😉

LeFnord avatar Oct 14 '16 21:10 LeFnord

@LeFnord , also it would be good to have access to initial add_swagger_documentation options. I mean, we put there security definitions which later could be taken into account on scopes injection and fetching.

texpert avatar Oct 14 '16 21:10 texpert

sorry @texpert for latency … but I think I didn't know exactly what you mean/expect did you expect to call a method to change/manipulate the generated data and also the parameters to do it?

LeFnord avatar Nov 01 '16 17:11 LeFnord

Yep, we have the possibility to specify the Security Definitions (SD) in the add_swagger_documentation hash. They're just in place to define what definitions and scopes are allowed on the API - for example, different authentication grant types could have different scopes.

Further on, Security Objects (SO) could be defined on endpoints and actions. But SO do not contain all the info from SD, especially the grant types are missing.

That's why there is necessary to have instant, but read-only access to these SD - to check the grant types of the incoming requests and thus to be able to differentiate traffic from users, servers, applications, whatever... very useful option regarding security! Moreover, this could serve for integration tests when building the APIs.

texpert avatar Nov 01 '16 18:11 texpert

I would like to take a stab at this. Is anyone currently working on it?

thogg4 avatar Mar 07 '17 00:03 thogg4

@thogg4 … it seems, nobody is currently working on, feel welcome :)

LeFnord avatar Mar 07 '17 08:03 LeFnord