Skip to content

Import Postman collections (v2.1) and environments #47

Closed

Description

@dataGriff

Why

Postman is where most teams' requests live today, and "can I bring my collection?" is the first question from anyone evaluating a replacement. apic import only reads OpenAPI 3 (internal/cli/import.go:17-22). Bruno's success with migration shows the value.

What

apic import collection.postman.json -o api --postman-env staging.postman_environment.json

Acceptance criteria:

  • Detects a Postman v2.1 collection by its info.schema; v2.0 is accepted where the shapes coincide, v1 is refused with a message.
  • Folders become files (<folder>.http), nested folders join with -; requests become named requests (kebab-case of the name, de-duplicated); the request description becomes # @description.
  • URL, method, headers, query, path variables (:id → {{id}}), raw/JSON/urlencoded/form-data bodies, and {{var}} placeholders map 1:1. GraphQL bodies map onto the GraphQL form once that lands.
  • Auth blocks map: bearer → # @auth bearer, basic → # @auth basic, apikey → # @auth apikey (once that exists, else a header), awsv4 → # @auth aws, oauth2 client credentials → # @auth oauth2. Others are listed in skipped.
  • Collection and environment variables become http-client.env.json ($shared for collection-level, one environment per --postman-env file); values marked secret go to the private file.
  • pm.test scripts: translate the trivial forms (pm.response.to.have.status(200), pm.expect(jsonData.x).to.eql(y), header equals) to # @assert; anything else is reported in skipped with the request and a one-line reason.
  • --json output extends the existing {"files", "requests", "base_url", "env_file", "skipped"} shape.

Where

New internal/postman/ (decoder as a small hand-written model like internal/openapi/model.go; no library), internal/cli/import.go (dispatch on file type), reuse the file-writing helpers from the OpenAPI importer.

Docs

docs/cli.md (import section), README command table row, docs/cheatsheet.md, docs/cookbook.md ("Migrate a Postman collection"), docs/comparison.md (Postman import row).

Tests

A fixture collection under internal/postman/testdata/ covering folders, every body type, every auth type, path variables and three pm.test shapes; golden .http output; environment mapping; refusal of v1.

Activity

  1. dataGriff commented on Sep 20, 2026

    @dataGriff
    OwnerAuthor

    Shipped in #103: apic import collection.postman.json -o api --postman-env staging.postman_environment.json, detected from the file (v2.1, v2.0 where the shapes coincide, v1 refused). Folders to files, requests to named requests, every body mode, bearer/basic/awsv4/oauth2/apikey auth (the collection's auth becomes auth.default), variables and environments to the env files with secrets in the private one, and the simple pm.test shapes to # @assert and # @capture. One deviation: what cannot be translated is reported under unsupported (request, what, reason) rather than skipped, so skipped keeps meaning "existing files kept". Docs: cli (import), cookbook (Migrate a Postman collection), comparison.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions