rstudio/plumber

Add support for multi-line annotations

Open

#911 aberto em 24 de jul. de 2023

Ver no GitHub
 (3 comments) (2 reactions) (0 assignees)R (257 forks)batch import
difficulty: intermediateeffort: mediumhelp wantedtheme: plumb() :sparkles:type: enhancement

Métricas do repositório

Stars
 (1.437 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Currently, annotations appear only to support single-line descriptions. For example, using the quickstart example with a lengthened @param field that is split across two lines:

# example.R
#* Echo the parameter that was sent in
#* @param msg The message to echo back. Lorem ipsum dolor sit amet, consectetur adipiscing elit,
#* sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
#* @get /echo
function(msg=""){
  [list](https://rdrr.io/r/base/list.html)(msg = [paste0](https://rdrr.io/r/base/paste.html)("The message is: '", msg, "'"))
}
plumber::pr("example.R") |>
    plumber::pr_set_docs("swagger") |>
    plumber::pr_run()

...results in the parameter documentation for msg being cut off at the end of the first line:

The message to echo back. Lorem ipsum dolor sit amet, consectetur adipiscing elit,

The same thing occurs with redoc:

library(redoc)
plumber::pr("example.R") |>
    plumber::pr_set_docs("redoc") |>
    plumber::pr_run()

The expected behaviour is for multi-line annotations to render the entire text, in the same way that roxygen documentation works. I've tried various levels of indentation for the second line, as well as adding \n to the first line, but it's always cut off.

I'm not sure whether this can be handled in plumber without upstream changes in swagger (etc.).

Guia do colaborador