Remove 'servers' parameter from /openapi.json swagger

Why can't you remove the 'servers' parameter from the swagger configuration and is there another way to do this?

pr(file) %>%
  pr_set_api_spec(function(spec) {
    spec$servers <- NULL
    #some more editing...
    spec
  }) %>%
  pr_run()

I'm using the current latest version of plumber installed from github (this example is simplified to get the main point across).

For context, I've created an R plumber API and am hosting it on Google Cloud Run (https://cloud.google.com/run).
Now I want to create a Google two factor authentication using Cloud Endpoints  |  Google Cloud. This involves editing the the swagger configuration (because it doesn't match up with how Google Endpoints expects it to be i.e. swagger 2.0 and not openapi 3.0). I've tried running this locally and on a VM with the same output.

There are three different ways of specifying api within pr_set_api_spec(). I've tried them all with the swagger configuration I need and servers always persists when it's not there in a yaml file or a list object.

You can not remove the servers section as it is executed after retrieving the spec.

Want you can do is set the value for the server using plumber options.
Plumber options — options_plumber • plumber (rplumber.io)

This topic was automatically closed after 45 days. 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.