dasavvy
December 14, 2022, 1:35pm
1
Hello fellow R users,
I have built an R Markdown and a swagger API. I am trying to find a way to get and display the name and the description of an endpoint (contained in the swagger API) in R Markdown without writing them manually.
Does somebody have an idea of how to proceed ?
Thank you in advance,
Dasavvy
meztez
December 14, 2022, 2:36pm
2
Something along those lines?
# Parse plumber OpenAPI json
library(plumber)
pr <- pr() |> pr_get("sum", sum, description = "An endpoint")
spec <- pr$getApiSpec()
# or spec <- jsonlite::parse_json("your_api_doc_json_file_url")
endpoints <- names(spec$paths)
descriptions <- vapply(spec$paths, \(x){x[[1]][["description"]]}, character(1), USE.NAMES = FALSE)
endpoints
descriptions
2 Likes
dasavvy
December 14, 2022, 8:38pm
3
This is very helpful! Thank you!
system
Closed
December 21, 2022, 8:38pm
4
This topic was automatically closed 7 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.