rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.4k stars 258 forks source link

Param schema definitions #818

Open kempspo opened 3 years ago

kempspo commented 3 years ago

I think it could be useful to be able to add a more flexible schema definition of the parameters. Such as being able to add the accepted values of the parameter on the Swagger interface.

This could definitely be added already by mucking around with the spec via pr_set_api_spec and modifying the list as necessary, but I definitely think it could be useful to abstract away.

I believe the change would be in the schema here

paramList <- list(
        name = p,
        description = endpointParams[[p]]$desc,
        `in` = location,
        required = required,
        schema = list(
          type = type,
          format = apiTypesInfo[[type]]$format,
          default = funcParams[[p]]$default

Here's an example per OpenAPI documentation

parameters:
  - in: query
    name: status
    schema:
      type: string
      enum:
        - available
        - pending
        - sold
schloerke commented 3 years ago

I like the idea, but it currently is hard to determine the difference between


I think this might be best for a custom decorator down the road.