Setting {{baseUrl}} when generating a collection from an OpenAPI spec

Context

I’m working on consolidating our OpenAPI spec to Postman.

Problem

Currently, when generating a new collection from an OpenAPI spec, all the new APIs within such collection has {{baseUrl}} in their request URL. This presents a slight inconvenience, since we already have environments setup with an appropriate endpoint.

I’ve looked around, but it does not seem like it is possible to change this variable to that we already have.

Question

What is the best/recommended way to approach this, aside from manually changing every API to use the correct variable?

Thank you.

I ran into this same issue trying to convert our manually-built Postman collections and environments to OpenAPI-generated ones, and ended up solving it like this in my Spring Java application (where we use the io.swagger.v3.oas library for OpenAPI generation):

This shows up like this in the Swagger UI, with each of the ServerVariables below that heading:

And then when we import the api-docs.json into Postman, it makes an API (or Collection if you use the GitHub - postmanlabs/openapi-to-postman: Plugin for converting OpenAPI 3.0 specs to the Postman Collection (v2) format library), which has these Collection variables:

(see the next comment for more, there is a limit on file uploads)

(pt. 2)

Then, as long as your environments in Postman have this variable setup:

You can make requests like this and it all works, regardless of which environment you have selected:
Screen Shot 2023-03-08 at 9.17.19 AM

Hope that helps!

The next issue I’m trying to work through is having URL params get auto-populated from examples in the OpenAPI definition (instead of these <string> placeholders), but I’m having struggles with that so reach out if you get further than me :slight_smile:
Screen Shot 2023-03-08 at 9.19.14 AM