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.brufile per request,collection.bru,folder.bruandenvironments/*.bru. - OpenCollection YAML, the format Bruno 3.0 recommends for new collections: a folder with
opencollection.yml, one.ymlfile per request,folder.ymlandenvironments/*.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.jsonoropencollection.yml, or a folder that holds it a level or two down. - File: a
.zipof a collection, or loose.bruor.ymlrequest files. Pickingbruno.jsonoropencollection.ymlreads its whole folder. - Paste text: one
.bruor.ymlrequest.
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:
| Option | Default | What it does |
|---|---|---|
| Folders to subfolders | On | Keeps the folders. Off, every request goes at the top of the collection. |
| Collection and folder variables to every environment | On | Postino 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.env | On | Bruno 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. |
| Authorization | On | Converts the auth of each request, inherited from its folder or the collection included. Off, requests have none. |
| Convert scripts, tests and assert | On | Converts scripts, tests, assert blocks and request variables. Off, scripts and tests are copied as comments. |
| Documentation | On | Writes the docs block in the Docs tab of each request. |
| Environment colors | On | Gives 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
| Bruno | Postino |
|---|---|
| Folder | Directory |
| Request | A .postino file named after the request |
URL with :id path parameters | The URL, with the path parameters' values filled in |
| Query parameters, headers, disabled ones included | The query and the headers, disabled ones kept disabled |
| Headers of the collection and its folders | Copied into each request, the nearest one winning |
| JSON, text, XML, form URL encoded and multipart bodies | The same body types; a multipart file becomes an @path upload |
| GraphQL requests | A JSON body with the query and its variables, as GraphQL is sent over HTTP |
| Basic, Bearer and API key auth, and inherited auth | The same auth |
| OAuth 2.0 auth | An OAuth 2.0 profile named after the collection, shared by the requests with the same settings, its secrets in .local.env, as for Postman |
| Docs | The 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.setVarand their kin becomeenv.getandenv.set, andbru.getRequestVarbecomesvars.get.req.getUrl(),req.setHeader(),req.getBody()and the other request methods becomereq.url,req.headers.set(),req.bodyand so on.res.bodyandres.getBody()becomeres.json(), since Bruno gives the parsed JSON and Postino the text.res.getStatus(),res.getHeader()andres.getResponseTime()becomeres.status,res.headers.get()andres.timeMs.expect(...).to.equal(...)and the other Chai assertions become Postino's matchers.- Each line of an
assertblock becomes atest()named after it:res.status: eq 200becomesexpect(res.status).toBe(200). Every Bruno operator converts, fromeqtoisArray. - Pre-request variables become
vars.set(), and post-response variables such astoken: res.body.tokenbecomeenv.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.envfiles. - 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.