Display in R markdown the name and the description of an endpoint (in swagger API)

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

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

This is very helpful! Thank you! :slight_smile:

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.