harspec GitHub

Reference

Command line

harspec HAR_FILE [options]
OptionDefaultMeaning
-o, --out DIRharspec-outOutput directory (created if missing).
-f, --formats LISTallComma list of generators, e.g. typescript,python.
--host HOSTbusiest hostOnly use requests to this host.
--title TEXThost nameTitle in the OpenAPI info block.
--jsonoffWrite openapi.json instead of openapi.yaml.
--no-clusteroffDo not detect mixed alphanumeric IDs.
--include-staticoffKeep html, js, css and image requests.
--list-generatorsList built-in and plugin generators, then exit.
--versionPrint the version.

Exit codes: 0 success, 1 unreadable or invalid HAR, or no API traffic found, 2 bad arguments.

Output files

FileGeneratorNotes
openapi.yaml / .jsonbuilt inOpenAPI 3.0.3. Always written.
AUTH.mdbuilt inAlways written.
client.tstypescriptNo runtime dependencies. Passes tsc --strict.
client.pypythonNeeds requests.
examples.shcurlUses $TOKEN and $BASE.
postman_collection.jsonpostmanCollection v2.1 with baseUrl and token variables.

Operation naming

Operation IDs come from the method and path: GET /users/{user_id}/posts becomes getUserPosts. Collections keep the plural (getPets), items use the singular (getPet). Duplicates get a numeric suffix. Python methods are the snake_case form (get_user_posts).

OpenAPI extensions

FieldMeaning
x-harspec-samplesNumber of captured requests behind the operation. Low numbers mean low confidence.

Using the spec with other tools

ToolHow
Swagger Editor / Swagger UIPaste or upload openapi.yaml.
Postman, Insomnia, BrunoImport the OpenAPI file or the Postman collection.
openapi-generatoropenapi-generator-cli generate -i openapi.yaml -g go -o ./client for languages harspec does not cover yet.
Mock servers (Prism)prism mock openapi.yaml