Importing from Bruno

Bruno keeps collections as plain files too, so moving over is a folder away. The import wizard reads both of Bruno's formats, converts requests, environments, scripts, tests and assertions, shows what converts before writing anything, and leaves a report of what needs a look. Your Bruno folder is never changed.

What it reads

  • .bru files, Bruno's original format: a folder with bruno.json, one .bru file per request, collection.bru, folder.bru and environments/*.bru.
  • OpenCollection YAML, the format Bruno 3.0 recommends for new collections: a folder with opencollection.yml, one .yml file per request, folder.yml and environments/*.yml.

Both may be mixed in one collection, as Bruno allows while migrating.

Importing

Bruno goes through the same three step wizard as OpenAPI and Postman. Open it from the sidebar's Import menu, Bruno (collection folder)…, from Import from Bruno… in the welcome tab, or from Import Bruno collection… in the command palette. Dropping the collection's folder, or a .zip of it, anywhere on the window opens it too, on the Options step. It works with or without a workspace open.

Step 1: Source

  • Folder: the collection's folder, the one with bruno.json or opencollection.yml, or a folder that holds it a level or two down.
  • File: a .zip of a collection, or loose .bru or .yml request files. Picking bruno.json or opencollection.yml reads its whole folder.
  • Paste text: one .bru or .yml request.

The format is detected from the content: a folder with bruno.json or opencollection.yml switches the wizard to Bruno. The list shows the collection, with its requests and folders, and each environment with its color and a checkbox; uncheck the ones you do not want.

Step 2: Options

The Destination block works as for OpenAPI, except that the Bruno folder never becomes the workspace: the converted collection always goes to a Postino workspace, and the .bru files stay where they were. Then the name of the collection, the environments, and what to convert:

OptionDefaultWhat it does
Folders to subfoldersOnKeeps the folders. Off, every request goes at the top of the collection.
Collection and folder variables to every environmentOnPostino activates one environment at a time, so the variables of the collection and its folders are copied into each one. A value of the environment wins.
Secrets to .local.envOnBruno keeps the values of secret variables on each machine, not in the collection, so they are created empty in .local.env for you to fill in. Off, they are left out.
AuthorizationOnConverts the auth of each request, inherited from its folder or the collection included. Off, requests have none.
Convert scripts, tests and assertOnConverts scripts, tests, assert blocks and request variables. Off, scripts and tests are copied as comments.
DocumentationOnWrites the docs block in the Docs tab of each request.
Environment colorsOnGives each environment the Postino color nearest to its Bruno color, in the workspace configuration. See Environment colors.

Step 3: Preview

The tree of requests, with a checkbox on each and what to know about it, and three counts: complete, with warnings and unsupported. Nothing has been written yet. The last button writes everything at once; if that fails, what the import created is removed. When some request needs a look, the last screen says how many and View report opens .postino/import-report.md, as for Postman.

Updating an imported collection

Import the same collection again, after a git pull in its repository or from a new .zip, and the Preview step offers Update existing or Import as new collection. The collection is recognized by its name, the one in bruno.json or opencollection.yml, wherever its folder or .zip is. Use the wizard as usual, or the command palette's Update collection from Bruno…. The list is the one of an OpenAPI update: added, changed with what changed, and removed, with a checkbox for each. Changed requests keep their scripts, tests and the values you edited. Environments are left as they are. Loose request files, without bruno.json or opencollection.yml, name no collection and always import as new.

Collections

BrunoPostino
FolderDirectory
RequestA .postino file named after the request
URL with :id path parametersThe URL, with the path parameters' values filled in
Query parameters, headers, disabled ones includedThe query and the headers, disabled ones kept disabled
Headers of the collection and its foldersCopied into each request, the nearest one winning
JSON, text, XML, form URL encoded and multipart bodiesThe same body types; a multipart file becomes an @path upload
GraphQL requestsA JSON body with the query and its variables, as GraphQL is sent over HTTP
Basic, Bearer and API key auth, and inherited authThe same auth
OAuth 2.0 authAn OAuth 2.0 profile named after the collection, shared by the requests with the same settings, its secrets in .local.env, as for Postman
DocsThe Docs tab

Not imported, and reported: SPARQL and file bodies, auth types Postino does not have (Digest, NTLM, AWS Signature, WSSE, OAuth 1.0), gRPC and WebSocket requests, scripts and tests of the collection or a folder (only those of each request are imported), and the collection's .env file with the process.env values it feeds.

Scripts, tests and assertions

A request's pre-request variables and script become its pre-request script. Its post-response variables, post-response script, assertions and tests become its post-response script, in the order Bruno runs them.

  • bru.getEnvVar, bru.setEnvVar, bru.getVar, bru.setVar and their kin become env.get and env.set, and bru.getRequestVar becomes vars.get.
  • req.getUrl(), req.setHeader(), req.getBody() and the other request methods become req.url, req.headers.set(), req.body and so on.
  • res.body and res.getBody() become res.json(), since Bruno gives the parsed JSON and Postino the text. res.getStatus(), res.getHeader() and res.getResponseTime() become res.status, res.headers.get() and res.timeMs.
  • expect(...).to.equal(...) and the other Chai assertions become Postino's matchers.
  • Each line of an assert block becomes a test() named after it: res.status: eq 200 becomes expect(res.status).toBe(200). Every Bruno operator converts, from eq to isArray.
  • Pre-request variables become vars.set(), and post-response variables such as token: res.body.token become env.set("token", res.json().token).

What has no equivalent stays as a comment, under the line // Imported from Bruno. What could not be converted is commented out below.: bru.sendRequest, bru.runRequest, bru.setNextRequest and the rest of the runner, cookies, res.headers read as an object, JSON schema assertions and require. Two differences remain after a conversion: Postino's variables are text, so a number stored with bru.setVar comes back as a string, and env.set keeps a value for the app session only, where bru.setEnvVar writes the environment file.

Environments

Each Bruno environment becomes environments/<name>.env. An environment that extends another gets the variables it does not set from it. Secret variables become empty entries of environments/<name>.local.env, out of git, and the report names them: fill them in before sending. With Environment colors on, each environment keeps a color close to the one it had in Bruno.

From the command line

postino import bruno <source> runs this import with the wizard's default choices, from the collection's folder, a .zip or .bru files. See the command line reference.

After importing

  • Fill in the secrets in the .local.env files.
  • Look at the report: it lists every body, auth and script that needs your attention.
  • Activate an environment, send a few requests and compare with Bruno.
  • Commit the result.

Found a mistake? Edit this page on GitHub or open an issue.

↑↓to move ↵to open /or Ctrl Kto search from any page