Closed JHibbard closed 6 years ago
Two options:
@get /__swagger__/
in your API. That would override whatever plumber would try to set. So an API like:#' @get /__swagger__/
function(){
"nope"
}
would return (JSON-encoded) nope
when a user visits /__swagger__/
, but /swagger.json
would still work.
swagger=TRUE
in run in your own API. https://github.com/trestletech/plumber/blob/master/R/plumber.R#L207-L246 This would require interacting with your plumber router programmatically (https://www.rplumber.io/docs/programmatic-usage.html), so it wouldn't be quite as simple.And I'm not 100% sure off the top of my head whether or not that code that I pointed you to uses any internal methods on the plumber router which might make it difficult for you to replicate externally.Thanks for the quick response. Option 1 seems to fail, I'm guessing the default /swagger/ route gets added after the user api handlers are added. I tested this by adding the custom /swagger/ endpoint to the 04-mean-sum example provided in the plumber package.
Huh. I was concerned about that but when I tested the API I pasted above, it actually worked for me.
What version are you on?
That was the problem. I installed the most recent version and it's working fine. Thanks for all your help :)
Is it possible to expose the JSON endpoint for the generated swagger spec without setting "swagger=TRUE" in run? I don't want users to access the default swagger live docs, but instead want them to use a custom docs page that requires the swagger JSON to work. Thanks! And this is a great project :)