My plumber api (swagger) no longer accepts '&' to separate multiple parameter input values.

My plumber api works fine when using a single value for a query parameter (e.g. 'in_subject' = A). However, when I add an additional value, separated by '&' , I get nothing (see fig). I'm pretty sure adding '&' between items in a list previously worked. Any help greatly appreciated!

Repro:

library(plumber)
library(dplyr)

subject <- c("A", "B", "C", "D", "E")
age <- c(23, 41, 32, 58, 26)

df <- data.frame(subject, age)

#* @apiTitle repro
#* Returns Data in JSON format
#* @param in_subject
#* @get /S

function(in_subject) {
  df %>%
    filter(
      subject == in_subject
    )
}

The ampersand gets encoded and is not part of the URL since you are using it within a Swagger input. To use multiple inputs, define your parameter as an array by encloding the type within square brackets.

library(plumber)
library(dplyr)

subject <- c("A", "B", "C", "D", "E")
age <- c(23, 41, 32, 58, 26)

df <- data.frame(subject, age)

#* @apiTitle repro
#* Returns Data in JSON format
#* @param in_subject:[string]
#* @get /S

function(in_subject) {
  df %>%
    filter(
      subject == in_subject
    )
}

Perfect, really appreciate your help!

This topic was automatically closed 21 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.