Possible to change the OpenAPI spec url?

I want to change the url of OpenAPI spec url from openapi.json to swagger.json. But I can't find any document or code about OpenAPI spec url. Is it possible?

library(plumber)

redirect <- function(req, res) {
  res$status <- 301 # redirect permanently
  res$setHeader("Location", "../openapi.json")
  res$body <- "redirecting..."
  res
}

pr() %>% pr_get("/swagger.json", redirect) %>% pr_run()
3 Likes

Thanks for reply. It's working with 301.
But is there any way without using redirecting ? In my case, the spec URL will be integrate with other tools, 301 may cause unexpected error.
Maybe there is a function could generate current pr object's openapi spec contents, then I can just response it ?

library(plumber)
pr <- pr()
pr %>% pr_get("/swagger.json", pr$getApiSpec) %>% pr_run()
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.