Skip to main content

hitspec import

Import API specifications from various formats and convert them to hitspec .http files.

Supported Formats

Nothing is dropped silently

Anything an importer cannot carry over is reported on stderr as warning: .... When the problem belongs to one request, it is also left in the generated file as a # TODO: comment above that request (for example an untranslated Postman test script or an unsupported curl flag). Every importer output passes hitspec validate. -o accepts a file or a directory (a trailing /, or an existing directory). For a directory, openapi writes one file per tag and the other formats write <source-name>.http.

hitspec import openapi

Import from an OpenAPI/Swagger specification.

Flags

Path parameters

/users/{id} becomes {{id}}, and the file defines @id with the parameter’s example, then default, then first enum value, then a value for its type (1, example, a fixed UUID, …). If two operations use the same parameter name with different defaults, the second gets its own variable named <operationId>_<param>.

One file per tag

With -o tests/ (or any existing directory) each tag becomes tests/<tag>.http. Operations without tags are grouped by their first path segment. Each file carries the @baseUrl and the path variables its own requests use.

Examples


hitspec import postman

Import from a Postman Collection v2.1 file.

Flags

Features

  • Converts Postman folders into request groups
  • Maps Postman dynamic variables to hitspec built-in functions ({{$guid}} becomes {{$uuid()}})
  • Collection variables become @name = value lines
  • A Postman environment export becomes an environments: entry in hitspec.yaml (written next to the output, or printed when writing to stdout)
  • Converts Bearer, Basic, API Key and Digest authentication to @auth, honoring the request, folder and collection levels (other types are reported)
  • Supports raw, URL-encoded, form-data (>>>multipart), GraphQL and file bodies
  • Translates pm.test scripts for the common patterns: pm.response.to.have.status(N), pm.expect(pm.response.code).to.eql(N), response time, header checks and pm.expect(jsonData.x).to.eql(y) (becomes expect body.x == y). Everything else is kept as # TODO: untranslated test: .... Requests without tests get no assertions.

Examples


hitspec import curl

Convert curl commands to hitspec format.

Flags

Supported curl flags

Flags that only change how curl prints or transfers (-s, -S, -v, -i, -f, --compressed, …) are ignored. Any other flag produces a warning, and a # TODO: above the request. Browser “Copy as cURL” commands (with $'...' quoting) are supported.
An uploaded file field keeps its form field name: -F avatar=@me.png becomes file avatar @me.png. The Postman, Insomnia and OpenAPI importers do the same. A field name that contains a space cannot be written that way; it falls back to file @path (field name file) with a warning.

Examples

Use @filename syntax to read curl commands from a file. The file supports line continuations with \.

hitspec import insomnia

Import from an Insomnia export file (v4 format).

Flags

Features

  • Request folders as name prefixes
  • Environments: a lone base environment becomes @name = value lines. When sub environments exist, all variables go to a hitspec.yaml environments: section (a base entry plus one per sub environment, each merged over the base), written next to the output, or printed to stderr when writing to stdout. An existing hitspec.yaml is never overwritten (hitspec.imported.yaml is written instead). hitspec finds hitspec.yaml from the working directory upward, so for a file written elsewhere pass it explicitly: hitspec run tests/api.http --config tests/hitspec.yaml --env dev.
  • Authentication (Bearer, Basic, API Key, Digest) as @auth
  • Request bodies (JSON, raw, form-urlencoded, multipart, GraphQL, file)
  • Headers and query parameters
  • Insomnia template tags ({% ... %}) are reported, not translated

Examples


hitspec export

Export hitspec requests as runnable commands or client code.

Formats

The same names the Studio export action uses. Query parameters (? key = value lines) and @auth (bearer, basic, API key) are included in every format. A form block (& key = value lines) is exported as the percent-encoded body the client sends (name=John%20Smith&e=a%26b), in curl and in the snippet formats. A request a format cannot express (multipart or file bodies outside curl) is skipped with a warning: on stderr and a SKIPPED comment in the output; if no request can be exported the command fails.

Flags

The exported command is run through sh (on Windows, the sh from Git for Windows, or cmd when there is none), so bash is not required. curl itself must be installed.
The --exec flag requires exactly one matching request. Use --name to filter to a single request when using --exec.

Auth Conversion (curl)

Examples

Sample Output

Use Cases

  • Debug failing tests by running the raw curl command
  • Share API calls with teammates who do not use hitspec
  • Use exported commands in shell scripts or other tools
  • Quickly test an endpoint outside the test framework
Last modified on October 19, 2026