Skip to main content

hitspec import

Import API specifications from various formats and convert them to hitspec .http files.
hitspec import <format> <source> [flags]

Supported Formats

FormatDescription
openapiOpenAPI 3.0/3.1 specs (YAML or JSON, local file or URL)
postmanPostman Collection v2.1 JSON files
curlcurl commands (inline or from a file)
insomniaInsomnia export files (v4 format)

hitspec import openapi

Import from an OpenAPI/Swagger specification.
hitspec import openapi <spec-file-or-url> [flags]

Flags

FlagShortDescriptionDefault
--output-oOutput file pathstdout
--base-urlOverride the base URL from the spec
--tagsFilter operations by tags (comma-separated)all
--no-testsSkip generating test assertionsfalse

Examples

hitspec import openapi api-spec.yaml -o tests/api.http

hitspec import postman

Import from a Postman Collection v2.1 file.
hitspec import postman <collection.json> [flags]

Flags

FlagShortDescriptionDefault
--output-oOutput file or directory pathstdout

Features

  • Converts Postman folders into request groups
  • Maps Postman dynamic variables to hitspec built-in functions ({{$guid}} becomes {{$uuid()}})
  • Converts Bearer, Basic, and API Key authentication
  • Supports raw, URL-encoded, and form-data bodies

Examples

hitspec import postman collection.json -o tests/api.http

hitspec import curl

Convert curl commands to hitspec format.
hitspec import curl <command-or-file> [flags]

Flags

FlagShortDescriptionDefault
--output-oOutput file pathstdout
--no-testsSkip generating test assertionsfalse

Supported curl flags

curl FlagDescription
-X, --requestHTTP method
-H, --headerRequest header
-d, --dataRequest body
-u, --userBasic auth (user:password)
-k, --insecureSkip SSL verification
-L, --locationFollow redirects
-A, --user-agentUser-Agent header
-e, --refererReferer header
-b, --cookieCookie header

Examples

hitspec import curl "curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{\"name\":\"John\"}'"
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).
hitspec import insomnia <export-file> [flags]

Flags

FlagShortDescriptionDefault
--output-oOutput file pathstdout
--no-testsSkip generating test assertionsfalse

Features

  • Request folders as file separators
  • Environment variables
  • Authentication (Bearer, Basic, API Key)
  • Request bodies (JSON, form data, raw)
  • Headers

Examples

hitspec import insomnia insomnia-export.json -o tests/api.http

hitspec export curl

Export hitspec requests as executable curl commands.
hitspec export curl <file> [flags]

Flags

FlagShortDescriptionDefault
--name-nFilter by request name (glob pattern)all
--tags-tFilter by tags (comma-separated)all
--output-oOutput file pathstdout
--env-eEnvironment for variable resolutionnone
--execExecute the curl command directlyfalse
--verbose-vInclude -v in curl outputfalse
The --exec flag requires exactly one matching request. Use --name to filter to a single request when using --exec.

Auth Conversion

hitspeccurl
@auth bearer <token>-H 'Authorization: Bearer <token>'
@auth basic <user> <pass>-u '<user>:<pass>'
@auth apiKey <header> <key>-H '<header>: <key>'
@auth digest <user> <pass>--digest -u '<user>:<pass>'

Examples

hitspec export curl tests/api.http

Sample Output

# Request: Login
curl -X POST 'https://api.example.com/auth/login' \
  -H 'Content-Type: application/json' \
  -d '{"username": "john", "password": "secret"}'

# Request: Get Profile
curl -X GET 'https://api.example.com/profile' \
  -H 'Authorization: Bearer {{login.token}}'

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