{"id":47356265,"url":"https://github.com/bcoughlan/openapi-commander","last_synced_at":"2026-03-18T02:40:36.950Z","repository":{"id":45516277,"uuid":"497158492","full_name":"bcoughlan/openapi-commander","owner":"bcoughlan","description":"Generate a Node.js command line tool from an OpenAPI definition","archived":false,"fork":false,"pushed_at":"2025-08-18T23:15:27.000Z","size":1275,"stargazers_count":27,"open_issues_count":5,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-19T00:26:40.252Z","etag":null,"topics":["cli","openapi3"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcoughlan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-27T22:55:07.000Z","updated_at":"2025-08-18T23:15:31.000Z","dependencies_parsed_at":"2025-08-19T00:28:28.217Z","dependency_job_id":null,"html_url":"https://github.com/bcoughlan/openapi-commander","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/bcoughlan/openapi-commander","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcoughlan%2Fopenapi-commander","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcoughlan%2Fopenapi-commander/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcoughlan%2Fopenapi-commander/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcoughlan%2Fopenapi-commander/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcoughlan","download_url":"https://codeload.github.com/bcoughlan/openapi-commander/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcoughlan%2Fopenapi-commander/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30643006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-18T01:41:58.583Z","status":"online","status_checked_at":"2026-03-18T02:00:07.824Z","response_time":104,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","openapi3"],"created_at":"2026-03-18T02:40:36.398Z","updated_at":"2026-03-18T02:40:36.939Z","avatar_url":"https://github.com/bcoughlan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenAPI Commander\n\nGenerate a Node.js command line tool from an OpenAPI definition using the\n[commander](https://www.npmjs.com/package/commander) library.\n\n```\n$ node petstore.js\n\nUsage: petstore [options] [command]\n\nOptions:\n  -p, --print \u003cmode\u003e     Print the HTTP request instead of sending it. (choices: \"curl\", \"plain\")\n  -s, --server \u003cserver\u003e  Server to use\n  -a, --auth \u003cauth\u003e      Authorization header to send\n  -h, --help             display help for command\n\nCommands:\n  pet                    Everything about your Pets\n  user                   Operations about user\n  help [command]         display help for command\n\n$ node petstore.js pet getPetById 1\nStatus: 200\n{\n  \"id\": 1,\n  \"category\": {\n    \"id\": 1,\n    \"name\": \"Hola\"\n  },\n}\n```\n\nIt can be used as a starter for writing command line tools that talk to APIs,\nor as an alternative to using curl to work with APIs.\n\n\u003c!-- generated with \"markdown-toc -i README.md\" --\u003e\n\u003c!-- toc --\u003e\n\n- [Features](#features)\n- [Setup](#setup)\n- [Examples](#examples)\n  * [Commands grouped by tag](#commands-grouped-by-tag)\n  * [Basic GET example](#basic-get-example)\n  * [Global options](#global-options)\n    + [Custom server](#custom-server)\n    + [Set Authorization header](#set-authorization-header)\n    + [Print request without sending](#print-request-without-sending)\n    + [Print a curl command of the request](#print-a-curl-command-of-the-request)\n  * [Print example request bodies](#print-example-request-bodies)\n- [Build standalone binaries](#build-standalone-binaries)\n- [A very incomplete TODO list...](#a-very-incomplete-todo-list)\n- [Contributing](#contributing)\n\n\u003c!-- tocstop --\u003e\n\n\n# Features\n\n- Generate clean code from your spec.\n- Supports Swagger 2, OpenAPI 3.0 and 3.1.\n- Show examples of request bodies, using examples from the spec or generated with [openapi-sampler](https://github.com/Redocly/openapi-sampler).\n- Verbose mode to see response headers.\n- Print a curl command of the request.\n\n# Setup\n\n1. Create an npm project with `npm init` or use an existing one. Your Node.js version must be 16+\n\n2. Install dependencies\n\n** Note: If your project still uses CommonJS, install `openapi-commander@3` and use `.js` for the output extension.**\n\n```\nnpm install commander\nnpm install --save-dev openapi-commander\n```\n\n3. Generate the CLI code\n\n```\nnpx openapi-commander generate \u003cpath or URL to spec\u003e \u003coutput file\u003e\n```\n\ne.g.\n\n```\nnpx openapi-commander generate https://raw.githubusercontent.com/OAI/OpenAPI-Specification/old-v3.0.4-dev/examples/v3.0/petstore.yaml petstore.mjs\n```\n\n4. Run\n\n```\nnode petstore.js ...\n```\n\n# Examples\n\n## Subcommands\n\nThe commands are grouped by their first tag in the OpenAPI spec (the same logic\nthat Swagger UI uses).\n\n```\n~/petstore$ node petstore.js pet\nUsage: petstore pet [options] [command]\n\nEverything about your Pets\n\nOptions:\n  -h, --help                           display help for command\n\nCommands:\n  updatePet [options] \u003cbody\u003e           Update an existing pet\n  addPet [options] \u003cbody\u003e              Add a new pet to the store\n  findPetsByStatus [options]           Finds Pets by status\n  findPetsByTags [options]             *DEPRECATED* Finds Pets by tags\n  getPetById \u003cpetId\u003e                   Find pet by ID\n  updatePetWithForm [options] \u003cpetId\u003e  Updates a pet in the store with form data\n  deletePet [options] \u003cpetId\u003e          Deletes a pet\n  uploadFile [options] \u003cpetId\u003e         uploads an image\n  help [command]                       display help for command\n```\n\n\n## Basic GET example\n\n```\n~/petstore$ node petstore.js pet getPetById 1\nStatus: 200\n{\n  \"id\": 1,\n  \"category\": {\n    \"id\": 1,\n    \"name\": \"Hola\"\n  },\n  \"name\": \"Perrito\",\n  \"photoUrls\": [\n    \"/tmp/inflector995596007222725944.tmp\"\n  ],\n  \"tags\": [\n    {\n      \"id\": 1,\n      \"name\": \"Bizcocho\"\n    }\n  ],\n  \"status\": \"available\"\n}\n```\n\nYou can also add the `-v` flag to show response headers.\n\n## Global options\n\n### Custom server\n\n```\n~/petstore$ node petstore.js -s https://mypetstore.example pet getPetById 1\n```\n\nAlternatively you can override it by setting the environment variable `{COMMANDNAME}_SERVER`, e.g. `PETSTORE_SERVER`.\n\n### Set Authorization header\n\n```\n~/petstore$ node petstore.js -a 'Bearer mytoken' getPetById 1\n```\n\nAlternatively you can override it by setting the environment variable `{COMMANDNAME}_AUTH`, e.g. `PETSTORE_AUTH`.\n\n### Print request without sending\n\n```\n~/petstore$ node petstore.js pet -a 'Bearer mytoken' -s https://mypetstore.example getPetById 1 --print plain\nGET https://mypetstore.example/pet/1\nAuthorization: Bearer mytoken\nAccept: application/json\n```\n\n### Print a curl command of the request\n\n```\n~/petstore$ node petstore.js pet -a 'Bearer mytoken' -s https://mypetstore.example getPetById 1 --print curl\ncurl -X GET -H 'Authorization: Bearer mytoken' -H 'Accept: application/json' 'https://mypetstore.example/pet/1'\n```\n\n## Print example request bodies\n\n```\n~/petstore$ node petstore.js pet updatePet examples\nExample for application/json:\n{\n  \"id\": 10,\n  \"name\": \"doggie\",\n  \"category\": {\n    \"id\": 1,\n    \"name\": \"Dogs\"\n  },\n  \"photoUrls\": [\n    \"string\"\n  ],\n  \"tags\": [\n    {\n      \"id\": 0,\n      \"name\": \"string\"\n    }\n  ],\n  \"status\": \"available\"\n}\n```\n\n# Build standalone binaries\n\nTo build multi-platform standalone binaries platform I recommend [vercel/pkg](https://github.com/vercel/pkg).\n\n# A very incomplete TODO list...\n\nThe top priority is to beef up the test suite.\n\n- Syntax highlighting of examples\n- Implement different security/auth types.\n- Auto-detect request body type from file.\n- Show JSON \u0026 YAML examples with comments for field descriptions.\n  -\u003e Strip comments from JSON when passing in\n- Strip html/markdown from description\n- More serialization options https://swagger.io/docs/specification/serialization/\n- application/x-www-form-urlencoded content types.\n- Server templating.\n- Autocomplete.\n\n# Contributing\n\nThis is a hobby side project so I have limited time to work on issues but I will \ndo my best to discuss issues, review PRs and keep the project maintained. Please\nopen an issue for discussion before opening any significant PRs to avoid any\ndisappointment about project scope.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcoughlan%2Fopenapi-commander","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcoughlan%2Fopenapi-commander","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcoughlan%2Fopenapi-commander/lists"}