### Interact with mock server Source: https://context7.com/openapistack/openapicmd/llms.txt Example workflow for starting a mock server and performing requests against it. ```bash openapi mock ./petstore.yml --port 3000 ``` ```bash curl http://localhost:3000/pets ``` ```bash curl -X POST http://localhost:3000/pets \ -H "Content-Type: application/json" \ -d '{"name": "Garfield"}' ``` -------------------------------- ### Example API Test Workflow Source: https://context7.com/openapistack/openapicmd/llms.txt A typical workflow for setting up and running API tests, involving loading the definition, starting a mock server, adding tests, and executing them. ```bash # 1. Load definition openapi load ./openapi.yml # 2. Start mock server in background openapi mock ./openapi.yml --port 3000 & # 3. Add tests for all operations openapi test add --auto --server http://localhost:3000 # 4. Run tests openapi test --server http://localhost:3000 ``` -------------------------------- ### Start Swagger UI with Definition File Source: https://github.com/openapistack/openapicmd/blob/main/README.md Starts a Swagger UI instance using a specified OpenAPI definition file. ```bash openapi swagger-ui ./openapi.yml ``` -------------------------------- ### Start Swagger UI Instance Source: https://github.com/openapistack/openapicmd/blob/main/README.md Launches a Swagger UI instance. This is the default behavior when no definition file is provided. ```bash openapi swagger-ui ``` -------------------------------- ### CLI Command: openapi swagger-ui Source: https://github.com/openapistack/openapicmd/blob/main/README.md Starts a local Swagger UI server or bundles the documentation into a static directory. ```APIDOC ## CLI Command: openapi swagger-ui [DEFINITION] ### Description Starts a local Swagger UI instance for the provided OpenAPI definition file or bundles it into a static site directory. ### Arguments - **DEFINITION** (string) - Optional - Path to the input OpenAPI definition file. ### Flags - **-B, --bundle** (string) - Optional - Bundle a static site to the specified directory. - **-C, --strip** (string) - Optional - Strip optional metadata (default|all|openapi_client_axios|openapi_backend). - **-E, --exclude-ext** (string) - Optional - Specify an OpenAPI extension to exclude parts of the spec. - **-H, --header** (string) - Optional - Add request headers when calling remote URLs. - **-I, --inject** (string) - Optional - Inject JSON to definition with deep merge. - **-R, --root** (string) - Optional - Override API root path. - **-S, --server** (string) - Optional - Override servers definition. - **-p, --port** (number) - Optional - Port to run the server on (default: 9000). - **--deeplinks** (boolean) - Optional - Allow deep linking (default: true). - **--expand** (string) - Optional - Default expansion setting (full|list|none, default: list). - **--filter** (boolean) - Optional - Enable filtering by tag (default: true). - **--logger** (boolean) - Optional - Log requests (default: true). - **--operationids** (boolean) - Optional - Display operationIds (default: true). - **--proxy** (boolean) - Optional - Set up a proxy for the API to avoid CORS issues. - **--requestduration** (boolean) - Optional - Display request durations (default: true). - **--withcredentials** (boolean) - Optional - Send cookies in "try it now" (default: true). ### Examples - `openapi swagger-ui` - `openapi swagger-ui ./openapi.yml` - `openapi swagger-ui ./openapi.yml --bundle outDir` ``` -------------------------------- ### Example: Add Tests for a Specific Operation Source: https://github.com/openapistack/openapicmd/blob/main/README.md This example shows how to add tests for a specific operationId, 'getPet', and include all available checks. ```bash openapi test add -o getPet --checks all ``` -------------------------------- ### Example: Add Tests for All Operations Source: https://github.com/openapistack/openapicmd/blob/main/README.md This example demonstrates adding automated tests for all operations in the API definition. ```bash openapi test add ``` -------------------------------- ### Install openapicmd Source: https://context7.com/openapistack/openapicmd/llms.txt Installs the openapicmd tool globally using npm and displays the help command. ```bash npm install -g openapicmd openapi help ``` -------------------------------- ### Start mock API server with openapi mock Source: https://context7.com/openapistack/openapicmd/llms.txt Launch a local server that validates requests and generates responses based on OpenAPI definitions. ```bash openapi mock ./openapi.yml ``` ```bash openapi mock ./openapi.yml --port 3000 ``` ```bash openapi mock ./openapi.yml --swagger-ui docs ``` ```bash openapi mock https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml ``` ```bash openapi mock ./openapi.yml --no-validate ``` ```bash openapi mock ./openapi.yml --no-logger ``` ```bash openapi mock ./openapi.yml --root /api/v1 ``` ```bash openapi mock ./openapi.yml --server http://localhost:9000 ``` -------------------------------- ### openapi mock Source: https://github.com/openapistack/openapicmd/blob/main/README.md Starts a local mock API server based on an OpenAPI definition. ```APIDOC ## `openapi mock [DEFINITION]` ### Description Start a local mock API server ### Method CLI Command ### Endpoint N/A (Mock Server) ### Parameters #### Arguments - **DEFINITION** (string) - Required - input definition file #### Flags - **-h, --help** (boolean) - Show CLI help. - **-p, --port** (number) - [default: 9000] port - **--logger, --no-logger** (boolean) - [default: true] log requests - **-S, --server** (string[]) - override servers definition - **-I, --inject** (JSON) - inject JSON to definition with deep merge - **-C, --strip** (string) - Strip optional metadata such as examples and descriptions from definition. Options: default, all, openapi_client_axios, openapi_backend - **-E, --exclude-ext** (string[]) - Specify an openapi extension to exclude parts of the spec - **-H, --header** (string[]) - add request headers when calling remote urls - **-R, --root** (string) - override API root path - **-U, --swagger-ui** (string) - Swagger UI endpoint - **--validate, --no-validate** (boolean) - [default: true] validate requests according to schema ### Request Example ```bash openapi mock ./openapi.yml openapi mock https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml ``` ### Response N/A (Starts a server) ### Error Handling N/A ``` -------------------------------- ### Example TypeScript Type Usage Source: https://context7.com/openapistack/openapicmd/llms.txt Demonstrates how to import and use generated TypeScript types with openapi-client-axios for type-safe API calls. ```typescript // openapi.d.ts generated file import type { Client } from 'openapi-client-axios'; import OpenAPIClientAxios from 'openapi-client-axios'; // Import generated types import type { Components, Paths, Client as PetStoreClient } from './openapi.d.ts'; // Create typed client const api = new OpenAPIClientAxios({ definition: './openapi.yml' }); const client = await api.init(); // Fully typed API calls const { data: pets } = await client.getPets(); const { data: pet } = await client.getPet({ id: 1 }); await client.createPet(null, { name: 'Garfield', status: 'available' }); ``` -------------------------------- ### Call API Endpoint with Operation ID and Request Body Source: https://github.com/openapistack/openapicmd/blob/main/README.md Use this command to create or update an API resource by specifying the operationId and providing a JSON request body. The example creates a pet named 'Garfield'. ```bash $ openapi call -o createPet -d '{ "name": "Garfield" }' ``` -------------------------------- ### Run ReDoc with openapi redoc Source: https://context7.com/openapistack/openapicmd/llms.txt Serve or bundle ReDoc documentation. Supports remote definitions and deployment bundling. ```bash openapi redoc ./openapi.yml ``` ```bash openapi redoc ./openapi.yml --port 8080 ``` ```bash openapi redoc ./openapi.yml --bundle ./docs ``` ```bash openapi redoc https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml ``` ```bash openapi redoc ./openapi.yml --no-logger ``` -------------------------------- ### Initialize New OpenAPI Definition Source: https://context7.com/openapistack/openapicmd/llms.txt Creates a new OpenAPI 3.0 definition file from scratch with configurable metadata. Supports outputting as YAML or JSON. ```bash openapi init --title 'My API' > openapi.yml ``` ```bash openapi init \ --title 'Pet Store API' \ --description 'API for managing pets' \ --version '1.0.0' \ --license mit \ --terms 'https://example.com/terms' \ --server 'https://api.example.com' \ > openapi.yml ``` ```bash openapi init --title 'My API' --json > openapi.json ``` ```bash openapi init --title 'My API' --license apache2 > openapi.yml ``` ```bash openapi init --title 'My API' --inject '{"tags":[{"name":"pets"}]}' > openapi.yml ``` -------------------------------- ### Run Swagger UI with openapi swagger-ui Source: https://context7.com/openapistack/openapicmd/llms.txt Serve or bundle Swagger UI documentation. Provides options for proxying, customization, and deployment. ```bash openapi swagger-ui ./openapi.yml ``` ```bash openapi swagger-ui ./openapi.yml --port 8080 ``` ```bash openapi swagger-ui https://petstore.swagger.io/v2/swagger.json ``` ```bash openapi swagger-ui ./openapi.yml --bundle ./docs ``` ```bash openapi swagger-ui ./openapi.yml --proxy ``` ```bash openapi swagger-ui ./openapi.yml \ --expand full \ --no-filter \ --no-deeplinks ``` ```bash openapi swagger-ui ./openapi.yml --operationids ``` ```bash openapi swagger-ui ./openapi.yml --no-requestduration ``` ```bash openapi swagger-ui ./openapi.yml --no-withcredentials ``` -------------------------------- ### Bundle Swagger UI to Static Site Source: https://github.com/openapistack/openapicmd/blob/main/README.md Bundles the Swagger UI into a static site and outputs it to the specified directory. This is useful for deploying a standalone Swagger UI. ```bash openapi swagger-ui ./openapi.yml --bundle outDir ``` -------------------------------- ### openapi help Source: https://github.com/openapistack/openapicmd/blob/main/README.md Display help for the openapi CLI or specific commands. ```APIDOC ## openapi help [COMMAND] ### Description Display help for openapi. ### Method CLI Command ### Endpoint N/A (CLI Command) ### Parameters #### Arguments - **COMMAND** (string[]) - Required - Command to show help for. #### Flags - **-n, --nested-commands** (boolean) - Include all nested commands in the output. ### Request Example ```bash openapi help openapi help call ``` ### Response N/A (CLI Output) ### Error Handling N/A (CLI Output) ``` -------------------------------- ### Configure Server Options Source: https://context7.com/openapistack/openapicmd/llms.txt Defines flags for setting the server port and toggling request logging. ```bash -p, --port # Port number (default: 9000) --logger / --no-logger # Enable/disable request logging ``` -------------------------------- ### Common CLI Flags - Output Format Source: https://context7.com/openapistack/openapicmd/llms.txt Reference for output format flags used with commands like 'read', 'init', and 'swagger2openapi'. ```bash # Output format (read, init, swagger2openapi) -f, --format # Output format: json|yaml|yml --json # Format as JSON --yaml # Format as YAML ``` -------------------------------- ### Display Help for Openapi CLI Source: https://github.com/openapistack/openapicmd/blob/main/README.md This command displays general help information for the openapi CLI. It can also show help for specific nested commands if the --nested-commands flag is used. ```bash $ openapi help [COMMAND...] ``` ```bash $ openapi help [COMMAND...] -n ``` -------------------------------- ### Run Swagger Editor with openapi swagger-editor Source: https://context7.com/openapistack/openapicmd/llms.txt Launch a local Swagger Editor instance for editing and validating OpenAPI definitions. ```bash openapi swagger-editor ``` ```bash openapi swagger-editor ./openapi.yml ``` ```bash openapi swagger-editor https://petstore.swagger.io/v2/swagger.json ``` ```bash openapi swagger-editor ./openapi.yml --port 8080 ``` ```bash openapi swagger-editor ./openapi.yml --no-logger ``` -------------------------------- ### Set Authentication Schemes Source: https://context7.com/openapistack/openapicmd/llms.txt Configures security schemes and credentials for API calls and testing. ```bash -s, --security # Use security scheme -k, --apikey # Set API key -t, --token # Set bearer token -u, --username # Set basic auth username -P, --password # Set basic auth password ``` -------------------------------- ### Load OpenAPI Definition Source: https://context7.com/openapistack/openapicmd/llms.txt Sets the default OpenAPI definition file for a workspace. Supports local files and remote URLs. Validation can be enabled. ```bash openapi load ./openapi.yml ``` ```bash openapi load https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml ``` ```bash openapi load ./openapi.yml --validate ``` -------------------------------- ### Manage authentication with openapi auth Source: https://context7.com/openapistack/openapicmd/llms.txt Store credentials in .openapiconfig for use with subsequent commands. Supports bearer tokens, API keys, and basic authentication. ```bash openapi auth ./openapi.yml ``` ```bash openapi auth ./openapi.yml --token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` ```bash openapi auth ./openapi.yml --security ApiKeyAuth --apikey secret123 ``` ```bash openapi auth ./openapi.yml --security BasicAuth --username admin --password password ``` ```bash openapi auth ./openapi.yml \ --security BearerAuth --token mytoken \ --security ApiKeyAuth --apikey mykey ``` -------------------------------- ### Convert Swagger to OpenAPI with openapi swagger2openapi Source: https://context7.com/openapistack/openapicmd/llms.txt Transform Swagger 2.0 definitions into OpenAPI 3.0.x format. ```bash openapi swagger2openapi ./swagger.json > openapi.yml ``` ```bash openapi swagger2openapi ./swagger.json --json > openapi.json ``` ```bash openapi swagger2openapi ./swagger.json --validate ``` -------------------------------- ### openapi auth [DEFINITION] Source: https://github.com/openapistack/openapicmd/blob/main/README.md Authenticates with APIs by writing configuration to .openapiconfig. This command supports various authentication methods including tokens, API keys, and basic authentication. ```APIDOC ## `openapi auth [DEFINITION]` ### Description Authenticate with apis (writes to .openapiconfig) ### Method CLI COMMAND ### Endpoint N/A (CLI command) ### Parameters #### Arguments - **DEFINITION** (string) - Required - input definition file #### Flags - **-B, --bundle** (boolean) - resolve remote $ref pointers - **-C, --strip** (string) - Strip optional metadata such as examples and descriptions from definition. Allowed values: default, all, openapi_client_axios, openapi_backend - **-D, --dereference** (boolean) - resolve $ref pointers - **-E, --exclude-ext** (string) - Specify an openapi extension to exclude parts of the spec. Default: x-internal - **-H, --header** (string array) - add request headers when calling remote urls - **-I, --inject** (JSON) - inject JSON to definition with deep merge. Example: `{"info":{"version":"1.0.0"}}` - **-P, --password** (string) - set basic auth password - **-R, --root** (string) - override API root path. Default: / - **-S, --server** (string array) - override servers definition. Example: `http://localhost:9000` - **-U, --remove-unreferenced** (boolean) - Remove unreferenced components, you can skip individual component being removed by setting x-openapicmd-keep to true - **-V, --validate** (boolean) - validate against openapi schema - **-h, --help** (boolean) - Show CLI help. - **-k, --apikey** (string) - set api key - **-s, --security** (string array) - use security scheme - **-t, --token** (string) - set bearer token - **-u, --username** (string) - set basic auth username ### Request Example ```bash openapi auth openapi auth --token eyJh... openapi auth --security ApiKeyAuth --apikey secret123 openapi auth --security BasicAuth --username admin --password password ``` ### Response This command writes configuration to `.openapiconfig` and does not return a response body in the typical API sense. Success is indicated by the absence of errors. ``` -------------------------------- ### Read and Manipulate OpenAPI Definitions Source: https://context7.com/openapistack/openapicmd/llms.txt Reads, parses, and outputs OpenAPI definition files. Supports format conversion, dereferencing, bundling, validation, and more. ```bash openapi read ./openapi.yml ``` ```bash openapi read ./openapi.yml -f json > openapi.json ``` ```bash openapi read https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml ``` ```bash openapi read ./openapi.yml --dereference ``` ```bash openapi read ./openapi.yml --bundle ``` ```bash openapi read ./openapi.yml --validate ``` ```bash openapi read ./openapi.yml --server http://api.example.com ``` ```bash openapi read ./openapi.yml --inject '{"info":{"version":"2.0.0"}}' ``` ```bash openapi read ./openapi.yml --strip default ``` ```bash openapi read ./openapi.yml --remove-unreferenced ``` ```bash openapi read ./openapi.yml --exclude-ext x-internal ``` -------------------------------- ### CLI Command: openapi test add Source: https://github.com/openapistack/openapicmd/blob/main/README.md Adds automated tests for API operations based on a provided definition file. ```APIDOC ## CLI Command: openapi test add ### Description Add automated tests for API operations based on an input definition file. ### Arguments - **DEFINITION** (string) - Optional - Input definition file path. ### Flags - **-B, --bundle** (boolean) - Optional - Resolve remote $ref pointers. - **-C, --strip** (string) - Optional - Strip optional metadata (default|all|openapi_client_axios|openapi_backend). - **-D, --dereference** (boolean) - Optional - Resolve $ref pointers. - **-E, --exclude-ext** (string) - Optional - Specify an openapi extension to exclude parts of the spec. - **-H, --header** (string) - Optional - Add request headers when calling remote urls. - **-I, --inject** (string) - Optional - Inject JSON to definition with deep merge. - **-P, --password** (string) - Optional - Set basic auth password. - **-R, --root** (string) - Optional - Override API root path. - **-S, --server** (string) - Optional - Override servers definition. - **-U, --remove-unreferenced** (boolean) - Optional - Remove unreferenced components. - **-V, --validate** (boolean) - Optional - Validate against openapi schema. - **-c, --checks** (string) - Optional - Checks to include in test. - **-d, --data** (string) - Optional - Request body. - **-n, --name** (string) - Optional - Test name. - **-o, --operation** (string) - Optional - OperationId. - **-p, --param** (string) - Optional - Parameter (key=value). - **-s, --security** (string) - Optional - Use security scheme. - **-t, --token** (string) - Optional - Set bearer token. - **-u, --username** (string) - Optional - Set basic auth username. - **--auto** (boolean) - Optional - Auto generate tests for all operations. ### Request Example $ openapi test add -o getPet --checks all ``` -------------------------------- ### Convert OpenAPI to Swagger 2.0 Source: https://context7.com/openapistack/openapicmd/llms.txt Use this command to convert OpenAPI specifications to Swagger 2.0 format. Supports dereferencing and bundling remote references. ```bash openapi swagger2openapi ./swagger.json --dereference ``` ```bash openapi swagger2openapi ./swagger.json --bundle ``` ```bash openapi swagger2openapi https://petstore.swagger.io/v2/swagger.json --yaml > openapi.yml ``` -------------------------------- ### Common CLI Flags - Parsing Options Source: https://context7.com/openapistack/openapicmd/llms.txt Reference for common parsing options available on most OpenAPI CLI commands, such as dereferencing, bundling, validation, and header injection. ```bash # Parsing options (available on most commands) -D, --dereference # Resolve all $ref pointers inline -B, --bundle # Resolve remote $ref pointers -V, --validate # Validate against OpenAPI schema -H, --header # Add request headers for remote URLs -S, --server # Override servers definition -I, --inject # Inject JSON with deep merge -E, --exclude-ext # Exclude paths with extension (e.g., x-internal) -C, --strip # Strip metadata (default|all|openapi_client_axios|openapi_backend) -U, --remove-unreferenced # Remove unreferenced components -R, --root # Override API root path ``` -------------------------------- ### Display API Information Source: https://context7.com/openapistack/openapicmd/llms.txt Displays detailed information about an OpenAPI definition. Options include listing operations, schemas, and security schemes. ```bash openapi info ./openapi.yml ``` ```bash openapi info https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml ``` ```bash openapi info ./openapi.yml --operations ``` ```bash openapi info ./openapi.yml --schemas ``` ```bash openapi info ./openapi.yml --security ``` ```bash openapi info ./openapi.yml --operations --schemas --security ``` -------------------------------- ### Convert Swagger 2.0 to OpenAPI 3.0 YAML Source: https://github.com/openapistack/openapicmd/blob/main/README.md Use this command to convert a Swagger 2.0 JSON definition file to an OpenAPI 3.0 YAML file. Redirect the output to a new file. ```bash openapi swagger2openapi --yaml ./swagger.json > openapi.yml ``` -------------------------------- ### Call API Endpoints Source: https://context7.com/openapistack/openapicmd/llms.txt Executes API calls directly from the command line using the OpenAPI definition. Supports interactive mode, parameters, request bodies, and authentication. ```bash openapi call ./openapi.yml -o getPets ``` ```bash openapi call ./openapi.yml -o getPet -p id=1 ``` ```bash openapi call ./openapi.yml -o searchPets -p status=available -p limit=10 ``` ```bash openapi call ./openapi.yml -o createPet -d '{"name": "Garfield", "status": "available"}' ``` ```bash openapi call ./openapi.yml -o getPets --include ``` ```bash openapi call ./openapi.yml -o getPets --verbose ``` ```bash openapi call ./openapi.yml -o getPets --token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... ``` -------------------------------- ### Run API Tests Source: https://context7.com/openapistack/openapicmd/llms.txt Executes configured API tests using Jest. Supports running all tests, specific operations, verbose output, authentication, and server overrides. ```bash openapi test ``` ```bash openapi test -o getPets ``` ```bash openapi test -o getPets -o getPet ``` ```bash openapi test --verbose ``` ```bash openapi test --token mytoken ``` ```bash openapi test --server http://localhost:3000 ``` ```bash openapi test --no-interactive ``` -------------------------------- ### Execute API calls with openapi call Source: https://context7.com/openapistack/openapicmd/llms.txt Perform API requests using an OpenAPI definition. Supports various authentication methods, server overrides, and non-interactive modes. ```bash openapi call ./openapi.yml -o getPets --security ApiKeyAuth --apikey secret123 ``` ```bash openapi call ./openapi.yml -o getPets --username admin --password secret ``` ```bash openapi call ./openapi.yml -o getPets --server http://localhost:3000 ``` ```bash openapi call ./openapi.yml -o getPets --no-interactive ``` -------------------------------- ### Add Tests for API Operations Source: https://github.com/openapistack/openapicmd/blob/main/README.md Use this command to add automated tests for API operations. Specify the input definition file and use flags to customize test generation and execution. ```bash openapi test add [DEFINITION] [-h] [-D] [-B] [-R /] [-H ...] [-V] [-S http://localhost:9000...] [-I {"info":{"version":"1.0.0"}}...] [-E x-internal] [-C default|all|openapi_client_axios|openapi_backend] [-U] [--auto] [-o operationId] [-n my test] [-c 2XXStatus...] [-p key=value...] [-d ] [-v] [--interactive] [-s ...] [-k ] [-t ] [-u ] [-P ] ``` -------------------------------- ### Convert Swagger 2.0 to OpenAPI 3.0.x Source: https://github.com/openapistack/openapicmd/blob/main/README.md This command converts Swagger 2.0 definitions to OpenAPI 3.0.x format. It supports various options for customization, including dereferencing, bundling, and output format. ```APIDOC ## `openapi swagger2openapi [DEFINITION]` ### Description Convert Swagger 2.0 definitions to OpenAPI 3.0.x. ### Method CLI Command ### Endpoint N/A (CLI Tool) ### Parameters #### Path Parameters - **DEFINITION** (string) - Required - input definition file #### Flags - **-B, --bundle** (boolean) - resolve remote $ref pointers - **-C, --strip** (string) - Strip optional metadata such as examples and descriptions from definition. Options: `default`, `all`, `openapi_client_axios`, `openapi_backend` - **-D, --dereference** (boolean) - resolve $ref pointers - **-E, --exclude-ext** (string) - Specify an openapi extension to exclude parts of the spec. Example: `x-internal` - **-H, --header** (string array) - add request headers when calling remote urls - **-I, --inject** (object) - inject JSON to definition with deep merge. Example: `{"info":{"version":"1.0.0"}}` - **-R, --root** (string) - override API root path. Example: `/` - **-S, --server** (string array) - override servers definition. Example: `http://localhost:9000` - **-U, --remove-unreferenced** (boolean) - Remove unreferenced components, you can skip individual component being removed by setting x-openapicmd-keep to true - **-V, --validate** (boolean) - validate against openapi schema - **-f, --format** (string) - output format. Options: `json`, `yaml`, `yml`. Default: `yaml` - **--json** (boolean) - format as json (short for -f json) - **--yaml** (boolean) - format as yaml (short for -f yaml) - **-h, --help** (boolean) - Show CLI help. ### Request Example ```bash openapi swagger2openapi --yaml ./swagger.json > openapi.yml ``` ### Response N/A (CLI Tool Output) ### Error Handling N/A (CLI Tool Output) ``` -------------------------------- ### Add API Tests Interactively Source: https://context7.com/openapistack/openapicmd/llms.txt Use this command to interactively add API tests for operations in an OpenAPI definition. You can specify operations, custom names, checks, parameters, and request bodies. ```bash openapi test add ./openapi.yml ``` ```bash openapi test add ./openapi.yml -o getPets ``` ```bash openapi test add ./openapi.yml -o getPets -n "list all pets" ``` ```bash openapi test add ./openapi.yml -o getPets --checks Success2XX --checks ValidResponseBody ``` ```bash openapi test add ./openapi.yml -o getPet -p id=1 ``` ```bash openapi test add ./openapi.yml -o createPet -d '{"name": "Garfield"}' ``` ```bash openapi test add ./openapi.yml --auto ``` ```bash openapi test add ./openapi.yml -o getPets --token mytoken ``` ```bash openapi test add ./openapi.yml -o getPets --no-interactive ``` -------------------------------- ### openapi read Source: https://github.com/openapistack/openapicmd/blob/main/README.md Reads and manipulates OpenAPI definition files. ```APIDOC ## `openapi read [DEFINITION]` ### Description Read and manipulate definition files ### Method CLI Command ### Endpoint N/A (File Operation) ### Parameters #### Arguments - **DEFINITION** (string) - Required - input definition file #### Flags - **-h, --help** (boolean) - Show CLI help. - **-D, --dereference** (boolean) - resolve $ref pointers - **-B, --bundle** (boolean) - resolve remote $ref pointers - **-R, --root** (string) - override API root path - **-H, --header** (string[]) - add request headers when calling remote urls - **-V, --validate** (boolean) - validate against openapi schema - **-S, --server** (string[]) - override servers definition - **-I, --inject** (JSON) - inject JSON to definition with deep merge - **-E, --exclude-ext** (string[]) - Specify an openapi extension to exclude parts of the spec - **-C, --strip** (string) - Strip optional metadata such as examples and descriptions from definition. Options: default, all, openapi_client_axios, openapi_backend - **-U, --remove-unreferenced, --no-remove-unreferenced** (boolean) - Remove unreferenced components, you can skip individual component being removed by setting x-openapicmd-keep to true - **-f, --format** (string) - [default: yaml] output format. Options: json, yaml, yml - **--json** (boolean) - format as json (short for -f json) - **--yaml** (boolean) - format as yaml (short for -f yaml) ### Request Example ```bash openapi read https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml openapi read ./openapi.yml -f json > openapi.json ``` ### Response Outputs the processed OpenAPI definition in the specified format. ### Error Handling N/A ``` -------------------------------- ### Call API Endpoint with Operation ID and Parameter Source: https://github.com/openapistack/openapicmd/blob/main/README.md This command calls an API endpoint using its operationId and provides a parameter. The parameter 'id' is set to '1'. ```bash $ openapi call -o getPet -p id=1 ``` -------------------------------- ### CLI Command: openapi typegen Source: https://github.com/openapistack/openapicmd/blob/main/README.md Generates TypeScript types from an OpenAPI definition file with various configuration options. ```APIDOC ## CLI Command: openapi typegen [DEFINITION] ### Description Generates types from an OpenAPI definition file. Supports dereferencing, bundling, and injecting custom JSON into the definition. ### Arguments - **DEFINITION** (string) - Optional - The path to the input OpenAPI definition file. ### Flags - **-A, --[no-]type-aliases** (boolean) - Generate module level type aliases for schema components. - **-B, --bundle** (boolean) - Resolve remote $ref pointers. - **-C, --strip** (string) - Strip optional metadata such as examples and descriptions. - **-D, --dereference** (boolean) - Resolve $ref pointers. - **-E, --exclude-ext** (string) - Specify an OpenAPI extension to exclude parts of the spec. - **-H, --header** (string) - Add request headers when calling remote URLs. - **-I, --inject** (string) - Inject JSON to definition with deep merge. - **-R, --root** (string) - Override API root path. - **-S, --server** (string) - Override servers definition. - **-U, --[no-]remove-unreferenced** (boolean) - Remove unreferenced components. - **-V, --validate** (boolean) - Validate against OpenAPI schema. - **-b, --banner** (string) - Include a banner comment at the top of the generated file. ### Request Example $ openapi typegen ./openapi.yml > openapi.d.ts ``` -------------------------------- ### CLI Command: openapi unload Source: https://github.com/openapistack/openapicmd/blob/main/README.md Unsets the default definition file for a workspace by updating the .openapiconfig file. ```APIDOC ## CLI Command: openapi unload ### Description Unset the default definition file for a workspace. This command writes changes to the .openapiconfig file. ### Request Example $ openapi unload ``` -------------------------------- ### Toggle Interactive Mode Source: https://context7.com/openapistack/openapicmd/llms.txt Enables or disables interactive prompts for call and test commands. ```bash --interactive / --no-interactive # Enable/disable interactive prompts ``` -------------------------------- ### Call API Endpoint with Operation ID Source: https://github.com/openapistack/openapicmd/blob/main/README.md Use this command to call a specific API endpoint identified by its operationId. No parameters or data are provided. ```bash $ openapi call -o getPets ``` -------------------------------- ### Unload OpenAPI Definition Source: https://context7.com/openapistack/openapicmd/llms.txt Removes the default OpenAPI definition file from the workspace configuration. ```bash openapi unload ``` -------------------------------- ### Generate TypeScript Types Source: https://context7.com/openapistack/openapicmd/llms.txt Generates TypeScript type definitions from OpenAPI specifications. Supports generation for openapi-client-axios and openapi-backend, with options for banners, module aliases, and dereferencing. ```bash openapi typegen ./openapi.yml > openapi.d.ts ``` ```bash openapi typegen ./openapi.yml --backend > openapi.d.ts ``` ```bash openapi typegen ./openapi.yml --client --backend > openapi.d.ts ``` ```bash openapi typegen ./openapi.yml --banner "// Auto-generated types - do not edit" > openapi.d.ts ``` ```bash openapi typegen ./openapi.yml --no-type-aliases > openapi.d.ts ``` ```bash openapi typegen ./openapi.yml --dereference > openapi.d.ts ``` ```bash openapi typegen https://petstore.swagger.io/v2/swagger.json > petstore.d.ts ``` -------------------------------- ### openapi call Source: https://github.com/openapistack/openapicmd/blob/main/README.md Call API endpoints using the openapi call command. This command allows you to interact with defined API endpoints by specifying the definition file, operation ID, parameters, and request body. ```APIDOC ## openapi call [DEFINITION] ### Description Call API endpoints ### Method CLI Command ### Endpoint N/A (CLI Command) ### Parameters #### Arguments - **DEFINITION** (string) - Required - input definition file #### Flags - **-h, --help** (boolean) - Show CLI help. - **-D, --dereference** (boolean) - resolve $ref pointers - **-B, --bundle** (boolean) - resolve remote $ref pointers - **-R, --root** (string) - override API root path - **-S, --server** (string[]) - override servers definition - **-H, --header** (string[]) - add request headers when calling remote urls - **-I, --inject** (string[]) - inject JSON to definition with deep merge - **-E, --exclude-ext** (string) - Specify an openapi extension to exclude parts of the spec - **-C, --strip** (string) - Strip optional metadata such as examples and descriptions from definition (default: `default`) - **-U, --remove-unreferenced** (boolean) - Remove unreferenced components, you can skip individual component being removed by setting x-openapicmd-keep to true - **-V, --validate** (boolean) - validate against openapi schema - **--interactive** (boolean) - enable CLI interactive mode (default: `true`) - **-o, --operation** (string) - operationId - **-p, --param** (string[]) - parameter (format: `key=value`) - **-d, --data** (string) - request body - **-i, --include** (boolean) - include status code and response headers the output - **-v, --verbose** (boolean) - verbose mode - **-s, --security** (string[]) - use security scheme - **-k, --apikey** (string) - set api key - **-t, --token** (string) - set bearer token - **-u, --username** (string) - set basic auth username - **-P, --password** (string) - set basic auth password ### Request Example ```bash openapi call -o getPets openapi call -o getPet -p id=1 openapi call -o createPet -d '{ "name": "Garfield" }' ``` ### Response N/A (CLI Output) ### Error Handling N/A (CLI Output) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.