-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
78 lines (56 loc) · 2.35 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
title: "Generates `Redoc` documentation from an OAS Compliant API"
output:
github_document:
fig_width: 9
fig_height: 5
---
<!-- badges: start -->
[](https://cran.r-project.org/package=redoc)
[](https://github.com/meztez/redoc/actions)
[](https://community.rstudio.com/tag/plumber)
<!-- badges: end -->
`redoc` is a collection of `HTML`, `JavaScript`, `CSS` and fonts assets that generate `Redoc` documentation from an OpenAPI Specification.
The main purpose of this package is to enable package authors to create APIs that are compatible with [redoc.ly](https://redocly.com/redoc/) and [openapis.org](https://www.openapis.org/).
Package authors providing web interfaces can serve the static files from `redoc_path()` using [httpuv](https://github.com/rstudio/httpuv) or [fiery](https://github.com/thomasp85/fiery). As a start, we can also browse them by running
```{r eval=FALSE}
library(redoc)
browseURL(redoc_index())
```
<img src="tools/readme/browse_redoc.png" width=450 />
## Installation
```r
remotes::install_github("https://github.com/meztez/redoc")
```
## Use with `plumber` R package
### `plumber` annotation syntax
```r
library(redoc)
#* @plumber
function(pr) {
pr$setDocs("redoc", theme = list(menu = list(backgroundColor = "#00DE9C")))
}
#* @get /hello
function() {
"hello"
}
```
### `plumber` programmatic usage
```r
library(plumber)
library(redoc)
pr() %>%
pr_get("hello", function() {"hello"}) %>%
pr_set_docs("redoc", theme = list(menu = list(backgroundColor = "#00DE9C"))) %>%
pr_run()
```
### Using `Redoc` API attributes
Further customize `Redoc` using its configuration object. Use nested named list for nested configuration options.
```r
pr()$setDocs("redoc", theme = list(menu = list(backgroundColor = "#00DE9C")), disableSearch = TRUE)
pr() %>% pr_set_docs("rapidoc", theme = list(menu = list(backgroundColor = "#00DE9C")), disableSearch = TRUE)
```
The full set of `Redoc` configuration options is supported.
To learn more about `Redoc` visit:
* [Redoc](https://redocly.com/redoc/)
* [Redoc configuration options](https://github.com/Redocly/redoc#redoc-options-object)