Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify API Request Body JSON Schema Options and Documentation? #469

Closed
stufield opened this issue Aug 3, 2019 · 0 comments · Fixed by #550
Closed

Specify API Request Body JSON Schema Options and Documentation? #469

stufield opened this issue Aug 3, 2019 · 0 comments · Fixed by #550

Comments

@stufield
Copy link

stufield commented Aug 3, 2019

Hi @schloerke,

Opening this new issue, hope this is the correct place.

I'm trying to recreate something similar to the example in @blairj09 talk at RStudio::conf2019 earlier this year, where the expected request Schema is returned in the Swagger interface, his example is here:

https://github.com/sol-eng/plumber-model/blob/master/R/model-api/entrypoint.R

Based on this example, I would like to specify the expected JSON format for incoming requests. The above entrypoint.R file generates a section in the Swagger Interface under the Example Value | Schema that looks like this:

{
  "cyl": 0,
  "hp": 0
}

However I would like the example/scheme to actually run and need to specify an array of data, i.e. multiple rows in the array, which can be easily converted to a data.frame downstream. The Schema must look like this, with [ and ]:

[
  {
    "cyl": 0,
    "hp": 0
  }
]

... or even better (with actual values for 2 rows):

[
  {
    "cyl": 25.8,
    "hp": 33.6
  },
  {
    "cyl": 23.6,
    "hp": 22.9
  }
]

Is there a way in the entrypoint.R file to specify the square brackets? I have noticed that it is possible to add actual values to the Swagger interface example by specifying an example entry rather than a properties entry in the schema section of the call. Though I am still unable to figure out how to add [ ] to the example.

Some examples and/or documentation about what the options are in specifying the JSON scheme via the entrypoint.R file would be very helpful (it seems others also think so). If I've missed something obvious please let me know. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant