Generate curl Commands from OpenAPI
Paste an OpenAPI or Swagger document and get one runnable curl example per endpoint, with sample params, request bodies and auth placeholders.
About this tool
OpenAPI specs are great for machines, but during debugging you often just need a
pasteable curl command for every endpoint. This tool reads an OpenAPI 3.x or
Swagger 2.0 document, walks every path and operation, fills in sample path/query
/header/body values, and emits deterministic curl examples without sending any
network requests.
It prefers examples from the spec, then defaults, enum values and schema formats.
Local $refs are resolved so shared schemas still produce useful bodies; remote
references are not fetched, so the tool stays offline and predictable.
A worked example
Paste this tiny spec:
openapi: 3.0.3
servers:
- url: https://petstore.example.com/v1
paths:
/pets/{petId}:
get:
summary: Get a pet
parameters:
- name: petId
in: path
required: true
schema: { type: integer, example: 42 }
- name: verbose
in: query
schema: { type: boolean, default: true }
responses:
'200': { description: OK }
With the default shell output, the generated command includes the server URL, path parameter and query parameter:
BASE_URL="https://petstore.example.com/v1"
# GET /pets/{petId} — Get a pet
curl -X GET \
"$BASE_URL/pets/42?verbose=true"
Useful controls
- Base URL override swaps the server URL without editing the spec.
- Authentication can follow the spec or force bearer/basic/API-key placeholders.
- Method, tag and path filters narrow a large spec to the endpoints you care about.
- Include optional params and fields turns minimal examples into fuller examples.
- Output format switches between a shell script, bare commands, Markdown, and JSON records.
- Schema expansion depth prevents recursive or very large schemas from exploding.
Limits and edge cases
- Remote
$reftargets are not fetched; unresolved values collapse tonull. - The generated samples are examples, not contract tests. They may need real IDs, tokens or environment-specific hostnames before you run them.
- JSON and YAML OpenAPI 3.x and Swagger 2.0 documents are supported. A document
without
pathsis rejected. - Multipart and form request bodies are represented with curl
-F/--data-urlencodestyle flags when the content type calls for it.
FAQ
Does this make any HTTP requests?
No. It only parses the spec and writes example commands. The generated curl
commands are plain text; nothing is sent until you copy one into a terminal and
run it yourself.
Where do request body values come from?
The sampler uses the most specific hint available: explicit example values,
then default, then the first enum value, then a format-aware placeholder such as
an email, UUID or date-time. Object schemas include required fields by default;
turn on optional fields when you want a fuller sample body.
How are auth headers handled?
auto reads the operation or top-level security requirements and the declared
security schemes. If a credential value is blank, the output uses shell
placeholders such as $TOKEN, $API_KEY or $API_USER:$API_PASSWORD so secrets
are not baked into generated docs.
Can I generate examples for only part of a large API?
Yes. Use a comma-separated method filter (get,post), a tag filter (pets), or a
path substring (/admin). Filters combine, so a command must satisfy every
non-empty filter to be included.
Developer & Automation Access
Run it from the terminal
Same engine as this page, headless — via the gizza CLI:
gizza tool openapi-to-curl "Paste OpenAPI 3.x or Swagger 2.0 JSON/YAML here"New to the CLI? Get gizza →
Open it by URL
Pre-fill and auto-run this tool with query parameters — the names match the API/CLI:
https://gizza.ai/tools/openapi-to-curl/?spec=Paste%20OpenAPI%203.x%20or%20Swagger%202.0%20JSON%2FYAML%20here&input_format=auto&base_url=https%3A%2F%2Fapi.example.com%2Fv1&auth=auto&auth_value=leave%20blank%20for%20%24TOKEN%20%2F%20%24API_KEY%20placeholders&methods=get%2Cpost&tags=pets%2Cadmin&path_filter=%2Fpets&include_optional=true&output_format=shell&multiline=true&pretty_body=true&include_comments=true&max_depth=4Machine-readable descriptor: tool.json — title + parameters JSON Schema for agents.
