sol-eng / plumber-model

Plumber ML Model deployment example
Apache License 2.0
44 stars 27 forks source link

Specify API Request Body Schema as an array? #4

Closed stufield closed 4 years ago

stufield commented 5 years ago

Hi James,

Sorry if this is the wrong place to post this, but I think it may be so obvious I'm missing something. I saw your talk at RStudio::conf2019 this year and loved it. I'm trying to recreate something similar to your simple model prediction API in my organization, however for other groups it would be great to clearly specify the expected JSON format of incoming requests. In your example (in endpoints.R) the "Example Value | Schema" that is displayed in Swagger is 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:

[
  {
    "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!