Allow overriding URL for staging OpenAPI resources

We use an OpenAPI resource for our retools apps. Our openapi spec has our production endpoints listed as "server" in it.

Retool seems to pick that value up automatically - however this has the downside where there is currently no way to only override this value when creating the staging version of that resource - you need to point to two different files. This means that every time our spec changes, we need to create a second copy of it for staging, and upload both files.

It would be awesome if we could point to a single file, and override the base URL it should use for staging in the retool UI..

6 Likes

I have the same problem pointing at the OpenAPI spec for a vendor, they host the spec in a single central location but host several different tenants for your use, all on which have a different base URL. Being able to override by env would be great. Right now I can't use the OpenAPI resource type.
Might be related to this.
https://community.retool.com/t/changing-environments-with-openapi-resources-does-not-work-as-expected/9340

We have the same problem! Would love to see a way to override this as we currently aren't able to use this resource type even though we have a detailed spec to start with.

Ant news in this feature? World ben very useful

is it not answered here? not the workaround, but where it was closed as solved

It is not answered there. Or at least it is not clear to me what the solution is. I didn't notice the workaround last time though, maybe it is something I can try too.

Hi there!

The way the fix was shipped is that if you have server variables set up, it should expose this field on the resource page, and you could set the variables to be different for each environment:

image

Hi @Tess,
I stumbled on this thread while looking for a solution for a similar problem as the OP. I'm also using an OpenAPI resource in retool which fetches an OpenAPI 3.0.0 spec which also includes more than one server endpoint:
{ ... "servers": [{ "url": "/some/path" }, { "url": "/another/path" }], ...}

However, I do not see the server variables section you've mentioned. Could you please elaborate how this feature works exactly?

Edit: I think you were referring to OpenAPI server variables here instead so I updated the OpenAPI spec accordingly. Now I'm receiving an error when using the following:

"servers": [
    {
      "url": "https://foo.bar/{baz}",
      "description": "Lorem ipsum",
      "variables": {
        "baz": {
          "enum": ["foo", "bar", "baz"],
          "default": "foo"
        }
      }
    }
  ],

Edit2: After applying this new resource in an app within Retool it's actually working and the server variable section is shown within the app's resource section. Thus, (more or less) everything is working as expected. Thanks!
It's worth noting though, that the server variable section was only visible for newly created resources - it was not visible for existing resources which point to the updated OpenAPI spec file. This might be a pitfall for someone else as well.

1 Like

Thank you for elaborating for me and sharing an example! Yes, this is what I meant by server variables.

To your second edit about new resources vs existing, it seems like we need a refresh schema button on the resource page - curious if these workarounds would help at all