Open aronatkins opened 5 years ago
cc @blairj09
Agree. I am also having trouble customizing the swagger interface in the entrypoint.R
file.
Sorry if this is the wrong place to post this, but I think it may be so obvious I'm missing something. I am trying to specify the expected JSON format of incoming requests. For example (in entrypoint.R
) :
schema = list(
title = "predict values",
required = c("cyl", "hp"),
properties = list(
cyl = list(type = "integer"), # is there a way to specify a default value here??
hp = list(type = "number")
)
)
results in Swagger like this:
{
"cyl": 0,
"hp": 0
}
Which shows the expected format for 1 row of data, however our input is a data frame of test values needed to generate predicted values, so I would like to specify an array, yet it is not obvious to me how to accomplish this. Here is what I am looking for (note [
and ]
):
[
{
"cyl": 0,
"hp": 0
},
{
"cyl": 0,
"hp": 0
}
]
Showing (for example) 2 rows of expected format. It seems this should be relatively simple, though extensive Googling has come up empty. Thanks in advance!
@stufield Can you open a new issue with your comment? I don't understand how the schema
is connected to swagger for you. (Will need more in your example to understand).
(Will hide these two comments in this issue once you've posted a new one.)
Sure no problem. I was going to do just that but saw this issue and they seemed similar enough. I will also try to clarify (reading now I see how you may be unclear) :(
Larger example by @aronatkins https://github.com/rstudio/plumber/issues/481#issuecomment-525752560
Came here to note that there is no documentation on the entrypoint.R
it is only referenced in the NEWS.md and in the Process a Plumber API docs.
"Alternatively, if an entrypoint.R file is found, it will take precedence and be responsible for returning a runnable router."
it is unclear to me what the entrypoint.R is and how it should be used
The
entrypoint.R
file exists to let developers construct their own custom router. The only documentation I could find is this reference in the help for thedir
argument toplumber::plumb
:This help is true, but most developers won't know what it means to return a runnable Plumber router.
There is one small example but its code is presented without explaining documentation: https://github.com/trestletech/plumber/tree/master/inst/examples/12-entrypoint