diff --git a/404.html b/404.html index c89c413..7334fb5 100644 --- a/404.html +++ b/404.html @@ -10,7 +10,7 @@ - + @@ -29,7 +29,7 @@ - + \ No newline at end of file diff --git a/assets/js/c70cd9ce.6947d4df.js b/assets/js/c70cd9ce.6947d4df.js new file mode 100644 index 0000000..627d9a6 --- /dev/null +++ b/assets/js/c70cd9ce.6947d4df.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunkopenapi_stack=self.webpackChunkopenapi_stack||[]).push([[1534],{4137:(e,n,a)=>{a.d(n,{Zo:()=>d,kt:()=>h});var t=a(7294);function i(e,n,a){return n in e?Object.defineProperty(e,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[n]=a,e}function o(e,n){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);n&&(t=t.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),a.push.apply(a,t)}return a}function p(e){for(var n=1;n=0||(i[a]=e[a]);return i}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(t=0;t=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(i[a]=e[a])}return i}var l=t.createContext({}),s=function(e){var n=t.useContext(l),a=n;return e&&(a="function"==typeof e?e(n):p(p({},n),e)),a},d=function(e){var n=s(e.components);return t.createElement(l.Provider,{value:n},e.children)},u="mdxType",c={inlineCode:"code",wrapper:function(e){var n=e.children;return t.createElement(t.Fragment,{},n)}},m=t.forwardRef((function(e,n){var a=e.components,i=e.mdxType,o=e.originalType,l=e.parentName,d=r(e,["components","mdxType","originalType","parentName"]),u=s(a),m=i,h=u["".concat(l,".").concat(m)]||u[m]||c[m]||o;return a?t.createElement(h,p(p({ref:n},d),{},{components:a})):t.createElement(h,p({ref:n},d))}));function h(e,n){var a=arguments,i=n&&n.mdxType;if("string"==typeof e||i){var o=a.length,p=new Array(o);p[0]=m;var r={};for(var l in n)hasOwnProperty.call(n,l)&&(r[l]=n[l]);r.originalType=e,r[u]="string"==typeof e?e:i,p[1]=r;for(var s=2;s{a.r(n),a.d(n,{assets:()=>l,contentTitle:()=>p,default:()=>c,frontMatter:()=>o,metadata:()=>r,toc:()=>s});var t=a(7462),i=(a(7294),a(4137));const o={title:"Quick Start: CLI",hide_title:!0,sidebar_position:0},p=void 0,r={unversionedId:"openapicmd/intro",id:"openapicmd/intro",title:"Quick Start: CLI",description:"openapicmd",source:"@site/docs/openapicmd/intro.md",sourceDirName:"openapicmd",slug:"/openapicmd/intro",permalink:"/docs/openapicmd/intro",draft:!1,editUrl:"https://github.com/openapistack/docs/edit/main/docs/openapicmd/intro.md",tags:[],version:"current",sidebarPosition:0,frontMatter:{title:"Quick Start: CLI",hide_title:!0,sidebar_position:0},sidebar:"tutorialSidebar",previous:{title:"Reference",permalink:"/docs/openapi-client-axios/api"},next:{title:"Generating types",permalink:"/docs/openapicmd/typegen"}},l={},s=[{value:"Features",id:"features",level:2},{value:"Quick Start",id:"quick-start",level:2},{value:"openapi auth [DEFINITION]",id:"openapi-auth-definition",level:2},{value:"openapi call [DEFINITION]",id:"openapi-call-definition",level:2},{value:"openapi help [COMMANDS]",id:"openapi-help-commands",level:2},{value:"openapi info [DEFINITION]",id:"openapi-info-definition",level:2},{value:"openapi init",id:"openapi-init",level:2},{value:"openapi load DEFINITION",id:"openapi-load-definition",level:2},{value:"openapi mock [DEFINITION]",id:"openapi-mock-definition",level:2},{value:"openapi read [DEFINITION]",id:"openapi-read-definition",level:2},{value:"openapi redoc [DEFINITION]",id:"openapi-redoc-definition",level:2},{value:"openapi swagger-editor [DEFINITION]",id:"openapi-swagger-editor-definition",level:2},{value:"openapi swagger-ui [DEFINITION]",id:"openapi-swagger-ui-definition",level:2},{value:"openapi swagger2openapi [DEFINITION]",id:"openapi-swagger2openapi-definition",level:2},{value:"openapi test",id:"openapi-test",level:2},{value:"openapi test add [DEFINITION]",id:"openapi-test-add-definition",level:2},{value:"openapi typegen [DEFINITION]",id:"openapi-typegen-definition",level:2},{value:"openapi unload",id:"openapi-unload",level:2}],d={toc:s},u="wrapper";function c(e){let{components:n,...a}=e;return(0,i.kt)(u,(0,t.Z)({},d,a,{components:n,mdxType:"MDXLayout"}),(0,i.kt)("div",{align:"center"},(0,i.kt)("img",{alt:"openapicmd logo",src:"/img/openapi-stack-logo.png",className:"max-w-[150px]"}),(0,i.kt)("h1",{className:"mb-6"},"openapicmd",(0,i.kt)("a",{href:"https://github.com/openapistack/openapicmd",target:"_blank"},(0,i.kt)("img",{className:"w-[1em] ml-2 relative top-1",src:"https://img.icons8.com/material-sharp/96/000000/github.png",alt:"GitHub"}))),(0,i.kt)("p",null,"openapicmd - The CLI for all things OpenAPI and Swagger"),(0,i.kt)("p",null,(0,i.kt)("a",{parentName:"p",href:"https://github.com/openapistack/openapicmd/actions?query=workflow%3ACI"},(0,i.kt)("img",{parentName:"a",src:"https://github.com/openapistack/openapicmd/workflows/CI/badge.svg",alt:"CI"})),"\n",(0,i.kt)("a",{parentName:"p",href:"https://github.com/openapistack/openapicmd/blob/main/LICENSE"},(0,i.kt)("img",{parentName:"a",src:"http://img.shields.io/:license-mit-blue.svg",alt:"License"})),"\n",(0,i.kt)("a",{parentName:"p",href:"https://www.npmjs.com/package/openapicmd"},(0,i.kt)("img",{parentName:"a",src:"https://img.shields.io/npm/v/openapicmd.svg",alt:"npm version"})),"\n",(0,i.kt)("a",{parentName:"p",href:"https://www.npmjs.com/package/openapicmd"},(0,i.kt)("img",{parentName:"a",src:"https://img.shields.io/npm/dw/openapicmd.svg",alt:"npm downloads"})),"\n",(0,i.kt)("img",{parentName:"p",src:"https://img.shields.io/npm/types/openapicmd.svg",alt:"npm type definitions"}),"\n",(0,i.kt)("a",{parentName:"p",href:"https://github.com/openapistack/openapicmd"},(0,i.kt)("img",{parentName:"a",src:"https://img.shields.io/github/stars/openapistack/openapicmd",alt:"GitHub stars"})),"\n",(0,i.kt)("a",{parentName:"p",href:"https://buymeacoff.ee/anttiviljami"},(0,i.kt)("img",{parentName:"a",src:"https://img.shields.io/badge/donate-buy%20me%20a%20coffee-orange",alt:"Buy me a coffee"})))),(0,i.kt)("h2",{id:"features"},"Features"),(0,i.kt)("ul",{className:"contains-task-list"},(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Read and convert local and remote JSON/YAML OpenAPI definition files"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Generate TypeScript types from OpenAPI definitions"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Use as a CLI client to easily call API endpoints"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Run Local Mock APIs"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Automate API tests and validate specs"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Run ",(0,i.kt)("a",{parentName:"li",href:"https://github.com/swagger-api/swagger-ui"},"Swagger UI")," or ",(0,i.kt)("a",{parentName:"li",href:"https://github.com/Redocly/redoc"},"ReDoc")," locally"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Bundle static ",(0,i.kt)("a",{parentName:"li",href:"https://github.com/swagger-api/swagger-ui"},"Swagger UI")," or ",(0,i.kt)("a",{parentName:"li",href:"https://github.com/Redocly/redoc"},"ReDoc")," sites"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Run ",(0,i.kt)("a",{parentName:"li",href:"https://github.com/swagger-api/swagger-editor"},"Swagger Editor")," locally"),(0,i.kt)("li",{parentName:"ul",className:"task-list-item"},(0,i.kt)("input",{parentName:"li",type:"checkbox",checked:!0,disabled:!0})," ","Convert Swagger to OpenAPI ")),(0,i.kt)("h2",{id:"quick-start"},"Quick Start"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},"npm install -g openapicmd\nopenapi help\n")),(0,i.kt)("p",null,"Or with npx:"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},"npx openapicmd\n")),(0,i.kt)("h1",{id:"commands"},"Commands"),(0,i.kt)("ul",null,(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-auth-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi auth [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-call-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi call [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-help-commands"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi help [COMMANDS]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-info-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi info [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-init"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi init"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-load-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi load DEFINITION"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-mock-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi mock [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-read-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi read [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-redoc-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi redoc [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-swagger-editor-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi swagger-editor [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-swagger-ui-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi swagger-ui [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-swagger2openapi-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi swagger2openapi [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-test"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi test"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-test-add-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi test add [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-typegen-definition"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi typegen [DEFINITION]"))),(0,i.kt)("li",{parentName:"ul"},(0,i.kt)("a",{parentName:"li",href:"#openapi-unload"},(0,i.kt)("inlineCode",{parentName:"a"},"openapi unload")))),(0,i.kt)("h2",{id:"openapi-auth-definition"},(0,i.kt)("inlineCode",{parentName:"h2"},"openapi auth [DEFINITION]")),(0,i.kt)("p",null,"Authenticate with apis (writes to .openapiconfig)"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},'USAGE\n $ openapi auth [DEFINITION] [-h] [-V] [-D] [-B] [-R ] [-H ] [-S ] [-I ] [-E\n ] [-C ] [-s ] [-k ] [-t ] [-u ] [-P ]\n\nARGUMENTS\n DEFINITION input definition file\n\nFLAGS\n -B, --bundle resolve remote $ref pointers\n -C, --strip=default|all|openapi_client_axios|openapi_backend Strip optional metadata such as examples and\n descriptions from definition\n -D, --dereference resolve $ref pointers\n -E, --exclude-ext=x-internal Specify an openapi extension to exclude parts of the\n spec\n -H, --header=... add request headers when calling remote urls\n -I, --inject={"info":{"version":"1.0.0"}}... inject JSON to definition with deep merge\n -P, --password= set basic auth password\n -R, --root=/ override API root path\n -S, --server=http://localhost:9000... override servers definition\n -V, --validate validate against openapi schema\n -h, --help Show CLI help.\n -k, --apikey= set api key\n -s, --security=... use security scheme\n -t, --token= set bearer token\n -u, --username= set basic auth username\n\nDESCRIPTION\n Authenticate with apis (writes to .openapiconfig)\n\nEXAMPLES\n $ openapi auth\n\n $ openapi auth --token eyJh...\n\n $ openapi auth --security ApiKeyAuth --apikey secret123\n\n $ openapi auth --security BasicAuth --username admin --password password\n')),(0,i.kt)("h2",{id:"openapi-call-definition"},(0,i.kt)("inlineCode",{parentName:"h2"},"openapi call [DEFINITION]")),(0,i.kt)("p",null,"Call API endpoints"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},'USAGE\n $ openapi call [DEFINITION] [-h] [-D] [-B] [-R ] [-H ] [-V] [-S ] [-I ] [-E\n ] [-C ] [--interactive] [-o ] [-p ] [-d ] [-i] [-v] [-s ] [-k ] [-t\n ] [-u ] [-P ]\n\nARGUMENTS\n DEFINITION input definition file\n\nFLAGS\n -B, --bundle resolve remote $ref pointers\n -C, --strip=default|all|openapi_client_axios|openapi_backend Strip optional metadata such as examples and\n descriptions from definition\n -D, --dereference resolve $ref pointers\n -E, --exclude-ext=x-internal Specify an openapi extension to exclude parts of the\n spec\n -H, --header=... add request headers when calling remote urls\n -I, --inject={"info":{"version":"1.0.0"}}... inject JSON to definition with deep merge\n -P, --password= set basic auth password\n -R, --root=/ override API root path\n -S, --server=http://localhost:9000... override servers definition\n -V, --validate validate against openapi schema\n -d, --data= request body\n -h, --help Show CLI help.\n -i, --include include status code and response headers the output\n -k, --apikey= set api key\n -o, --operation=operationId operationId\n -p, --param=key=value... parameter\n -s, --security=... use security scheme\n -t, --token= set bearer token\n -u, --username= set basic auth username\n -v, --verbose verbose mode\n --[no-]interactive [default: true] enable CLI interactive mode\n\nDESCRIPTION\n Call API endpoints\n\nEXAMPLES\n $ openapi call -o getPets\n\n $ openapi call -o getPet -p id=1\n\n $ openapi call -o createPet -d \'{ "name": "Garfield" }\'\n')),(0,i.kt)("h2",{id:"openapi-help-commands"},(0,i.kt)("inlineCode",{parentName:"h2"},"openapi help [COMMANDS]")),(0,i.kt)("p",null,"Display help for openapi."),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},"USAGE\n $ openapi help [COMMANDS] [-n]\n\nARGUMENTS\n COMMANDS Command to show help for.\n\nFLAGS\n -n, --nested-commands Include all nested commands in the output.\n\nDESCRIPTION\n Display help for openapi.\n")),(0,i.kt)("h2",{id:"openapi-info-definition"},(0,i.kt)("inlineCode",{parentName:"h2"},"openapi info [DEFINITION]")),(0,i.kt)("p",null,"Display API information"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},'USAGE\n $ openapi info [DEFINITION] [-h] [-D] [-B] [-R ] [-H ] [-V] [-S ] [-I ] [-E\n ] [-C ] [--security] [--operations] [--schemas]\n\nARGUMENTS\n DEFINITION input definition file\n\nFLAGS\n -B, --bundle resolve remote $ref pointers\n -C, --strip=default|all|openapi_client_axios|openapi_backend Strip optional metadata such as examples and\n descriptions from definition\n -D, --dereference resolve $ref pointers\n -E, --exclude-ext=x-internal Specify an openapi extension to exclude parts of the\n spec\n -H, --header=... add request headers when calling remote urls\n -I, --inject={"info":{"version":"1.0.0"}}... inject JSON to definition with deep merge\n -R, --root=/ override API root path\n -S, --server=http://localhost:9000... override servers definition\n -V, --validate validate against openapi schema\n -h, --help Show CLI help.\n --operations list operations in document\n --schemas list schemas in document\n --security list security schemes in document\n\nDESCRIPTION\n Display API information\n\nEXAMPLES\n $ openapi info https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml\n\n $ openapi info ./openapi.yml\n')),(0,i.kt)("h2",{id:"openapi-init"},(0,i.kt)("inlineCode",{parentName:"h2"},"openapi init")),(0,i.kt)("p",null,"Initialise a definition file from scratch"),(0,i.kt)("pre",null,(0,i.kt)("code",{parentName:"pre"},'USAGE\n $ openapi init [-h] [-T ] [-d ] [-v ] [--terms ] [--license mit|apache2] [-S\n ] [-I ] [-f json|yaml|yml | --json | --yaml]\n\nFLAGS\n -I, --inject={"info":{"version":"1.0.0"}}... inject JSON to definition with deep merge\n -S, --server=http://localhost:9000... override servers definition\n -T, --title= [default: My API] The title for the API\n -d, --description= Description for the API\n -f, --format=