OpenAPI Snippet Exporter
Export cURL, HTTPie, Postman v2.1 and JS fetch snippets from an OpenAPI spec.
Overview
Paste an OpenAPI spec and pick an operation to get copy-ready cURL, HTTPie, Postman v2.1, and JavaScript fetch snippets for that request. Path parameters, query strings, headers, and an example request body are filled in from the spec's schemas.
It's for developers integrating with an API spec'd in OpenAPI - whether you're writing onboarding docs, building a quick smoke test, or just figuring out what the request actually looks like. Reach for it when you'd rather not hand-translate parameters into a cURL command.
How it works
The exporter walks each operation, resolves parameters and request body schemas (using JSON Schema sample generation for example values), and emits formatted snippets. The output follows each tool's canonical syntax: cURL's -X and -H flags, HTTPie's natural-language style, Postman's v2.1 collection JSON, and fetch()'s options object.
Authentication schemes declared in the spec (bearerAuth, API key, basic auth) appear as placeholder headers so you know what to fill in.
Examples
- cURL for
GET /users/{id}:curl -X GET 'https://api.example.com/users/123' \ -H 'Authorization: Bearer <token>' - HTTPie equivalent:
http GET https://api.example.com/users/123 'Authorization:Bearer <token>' - JS fetch:
const res = await fetch('https://api.example.com/users/123', { headers: { Authorization: 'Bearer <token>' } }); - Postman v2.1 (excerpt):
{ "name": "Get user", "request": { "method": "GET", "url": "https://api.example.com/users/123", "header": [{"key": "Authorization", "value": "Bearer <token>"}] } }
FAQ
Are the example bodies realistic?
They're synthesised from the spec's request body schema using the same logic as the JSON Schema Sampler - structurally valid but containing placeholder values you'll want to replace.
Does it generate Postman environments?
No - just collection JSON. Variables like {{baseUrl}} aren't auto-extracted; the snippets use literal hostnames.
Can I export the whole spec at once?
Snippet generation is per-operation. For a bulk Postman collection, import the OpenAPI spec directly into Postman, which converts everything automatically.
Why doesn't my auth header appear?
The exporter only emits auth headers when the spec declares a security block at the operation or document level. Unsecured operations get no auth headers.