plumber_docs: Plumber 'register_doc()' information

Description Usage Details Examples

View source: R/plumber.R

Description

Normally documentation is registered in the '.onLoad()' method of the package. To avoid a circular dependency with 'swagger' when 'plumber' are starting up, ‘plumber' must retrieve this information manually on it’s startup.

Usage

1

Details

See the examples for how documentation should regularly be registered.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
## Suggested setup for other packages trying to register visual docs for plumber
.onLoad <- function(...) {
  plumber_register_ui <- function() {
    tryCatch({
      do.call(plumber::register_ui, plumber_docs())
    }, error = function(e) {
      message("Error registering swagger docs. Error: ", e)
    })
  }

  setHook(packageEvent("plumber", "onLoad"), function(...) {
    plumber_register_ui()
  })
  if ("plumber" %in% loadedNamespaces()) {
    plumber_register_ui()
  }
}

## End(Not run)

swagger documentation built on Sept. 13, 2020, 5:18 p.m.