📚 MicroRapid CLI Commands Reference

📋 Complete Command Reference

Core Commands

CommandPurposeExample
initCreate new project from OpenAPI specmrapids init my-api --from-url https://api.example.com/openapi.yaml
validateValidate OpenAPI specificationmrapids validate api-spec.json --strict
exploreDeep search across API specmrapids explore payment
envManage environmentsmrapids env list
listDiscover available operationsmrapids list --filter user --method POST
authManage authenticationmrapids auth detect --spec api.yaml
showView operation detailsmrapids show repos/get
runExecute an API operationmrapids run GetUser --param id=123 --env prod --profile api-key
doctorDiagnose configuration issuesmrapids doctor --fix
diffCompare API specificationsmrapids diff old.yaml new.yaml --breaking-only
genGenerate code/SDKs/fixturesmrapids gen sdk --language typescript
testRun API testsmrapids test --all --env staging --profile qa

Collection Commands

CommandPurposeExample
collection createCreate new collectionmrapids collection create my-tests
collection runExecute collectionmrapids collection run smoke-tests --env prod --profile api-key
collection listShow all collectionsmrapids collection list
collection showShow collection detailsmrapids collection show user-onboarding
collection validateValidate collection syntaxmrapids collection validate my-tests
collection testRun collection as testsmrapids collection test smoke-tests --env staging

Authentication Commands

CommandPurposeExample
auth detectDetect required authenticationmrapids auth detect --spec api.yaml
auth connectConfigure authenticationmrapids auth connect api-key
auth loginLogin to OAuth providermrapids auth login github
auth testTest authenticationmrapids auth test --profile github-main
auth validateValidate auth configurationmrapids auth validate --profile production
auth refreshRefresh OAuth tokensmrapids auth refresh --profile oauth-prod

Environment Commands

CommandPurposeExample
env listList all environmentsmrapids env list
env createCreate new environmentmrapids env create qa --base-url https://qa.api.com
env useSet default environmentmrapids env use staging
env showShow environment detailsmrapids env show production

🎯 Command Options Reference

init Command Options

mrapids init <project-name> [options]
OptionDescriptionExample
--from-url <url>Initialize from URL--from-url https://api.example.com/openapi.json
--from-file <file>Initialize from local file--from-file ./openapi.yaml
--template <type>Project template (minimal, rest, graphql)--template rest
--forceOverwrite existing directory--force
--allow-insecureAllow insecure HTTP connections--allow-insecure

list Command Options

mrapids list [options]
OptionDescriptionExample
--filter/-f <keyword>Search operations by keyword--filter user
--method/-m <METHOD>Filter by HTTP method--method POST
--limit <n>Limit results--limit 10
--format <type>Output format (table, json, simple)--format json

run Command Options

mrapids run <operation> [options]
OptionDescriptionExample
--param <key=value>Set parameter value--param id=123
--env <environment>Use specific environment--env production
--profile <profile>Use auth profile--profile github-main
--file <file>Request body from file--file request.json
-iInteractive mode-i
--minimalMinimal template (with -i)-i --minimal
--fullFull template (with -i)-i --full
--dry-runPreview without executing--dry-run
--as-curlShow as curl command--as-curl
--verboseDetailed output--verbose
--save-to-collectionSave successful request--save-to-collection
--save-as <name>Save with specific name--save-as user-fetch
--timeout <ms>Request timeout--timeout 5000
--retry <n>Number of retries--retry 3
--traceTrace HTTP traffic--trace
--replay-lastReplay last query--replay-last
--query-file <file>Use query file--query-file query.json
--help-queryShow query syntax help--help-query
--build-queryInteractive query builder--build-query
--format <type>Output format--format json
--auth <string>Direct auth (not recommended)--auth "Bearer token"

validate Command Options

mrapids validate <spec-file> [options]
OptionDescriptionExample
--strictTreat warnings as errors--strict
--lintCheck for best practices--lint
--rules <file>Custom linting rules--rules api-rules.yaml
--format <type>Output format (text, json)--format json

doctor Command Options

mrapids doctor [options]
OptionDescriptionExample
--fixAuto-fix issues--fix
--check <area>Check specific area--check auth
--env <environment>Check specific environment--env production
--quietQuiet mode--quiet
--format <type>Output format (text, json)--format json

Check areas:

  • config - Configuration files
  • auth - Authentication setup
  • spec - OpenAPI specification
  • env - Environment variables

diff Command Options

mrapids diff <old-spec> <new-spec> [options]
OptionDescriptionExample
--breaking-onlyShow only breaking changes--breaking-only
--fail-on-breakingExit with error on breaking changes--fail-on-breaking
--format <type>Output format (text, json, markdown)--format markdown
--quietSuppress output--quiet

gen Command Options

mrapids gen <type> [options]

Generation Types:

TypeDescriptionExample
sdkGenerate SDK clientmrapids gen sdk --language typescript
snippetsGenerate code examplesmrapids gen snippets --format curl
stubsGenerate server stubsmrapids gen stubs --framework express
fixturesGenerate test datamrapids gen fixtures --count 100

Common Options:

OptionDescriptionExample
--language <lang>Target language--language python
--output <dir>Output directory--output ./sdk
--package-name <name>Package name--package-name @company/api
--with-docsInclude documentation--with-docs
--with-testsInclude tests--with-tests
--with-examplesInclude examples--with-examples
--framework <name>Server framework--framework fastapi
--count <n>Number of fixtures--count 50
--seed <n>Random seed--seed 42
--format <type>Output format--format yaml

collection Command Options

mrapids collection <subcommand> [options]

collection run Options:

OptionDescriptionExample
--env <environment>Use environment--env staging
--profile <profile>Use auth profile--profile api-key
--var <key=value>Set variable--var userId=123
--fail-fastStop on first failure--fail-fast
--report <format>Report format (junit, json)--report junit

collection test Options:

OptionDescriptionExample
--env <environment>Use environment--env staging
--profile <profile>Use auth profile--profile qa-creds
--fail-fastStop on first failure--fail-fast
--report <format>Test report format--report junit

📖 Complete Examples

Basic API Execution

# Simple GET request
mrapids run GetUser --param id=123

# With environment and authentication
mrapids run GetUser \
  --param id=123 \
  --env production \
  --profile api-key-prod

# POST with file and save to collection
mrapids run CreateUser \
  --file user-data.json \
  --env staging \
  --profile oauth-staging \
  --save-to-collection

Working with GitHub API

# Initialize GitHub API project
mrapids init github-api \
  --from-url https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json

# List repository operations
mrapids list --filter repo --method POST

# Get repository details
mrapids run repos/get \
  --param owner=microsoft \
  --param repo=vscode \
  --env production \
  --profile github-main

# Create repository with interactive mode
mrapids run repos/create-for-user -i
# Edit the generated template, then:
mrapids run repos/create-for-user \
  --file create_repo_request.json \
  --env production \
  --profile github-main \
  --save-to-collection

Authentication Setup

# Detect required authentication
mrapids auth detect --spec api.yaml

# Configure API key authentication
mrapids auth connect api-key

# Login to GitHub OAuth
mrapids auth login github

# Test authentication profile
mrapids auth test --profile github-main

# Validate production credentials
mrapids auth validate --profile production

Environment Management

# List all environments
mrapids env list

# Create QA environment
mrapids env create qa --base-url https://qa-api.example.com

# Switch default environment
mrapids env use staging

# Show environment details
mrapids env show production

Collection Management

# Create new collection
mrapids collection create smoke-tests

# Validate collection syntax
mrapids collection validate smoke-tests

# Run collection with variables
mrapids collection run user-onboarding \
  --env staging \
  --profile test-creds \
  --var email="test@example.com" \
  --var username="testuser"

# Run as tests with report
mrapids collection test regression-suite \
  --env staging \
  --profile qa-automation \
  --report junit > test-results.xml

API Validation and Testing

# Validate OpenAPI spec
mrapids validate api-spec.yaml --strict --lint

# Check for breaking changes
mrapids diff v1.0/api.yaml v2.0/api.yaml --breaking-only

# Run all tests
mrapids test --all --env staging --profile qa

# Diagnose issues
mrapids doctor --env production --fix

Code Generation

# Generate TypeScript SDK
mrapids gen sdk \
  --language typescript \
  --output ./sdk/typescript \
  --package-name "@company/api-client" \
  --with-docs \
  --with-tests

# Generate test fixtures
mrapids gen fixtures \
  --count 100 \
  --seed 42 \
  --output ./test-data

# Generate curl examples
mrapids gen snippets \
  --format curl \
  --output ./docs/examples

Advanced Query Building

# Interactive query builder
mrapids run searchProducts --build-query

# Complex query with filters
mrapids run searchProducts \
  --param q="category:electronics price:>100" \
  --param sort="price:asc" \
  --param page=1 \
  --param limit=20 \
  --env production \
  --profile api-key

# Use query file
cat > query.json << EOF
{
  "filter": "status = 'active' and created >= '2024-01-01'",
  "sort": "created:desc",
  "page": 1,
  "limit": 50
}
EOF

mrapids run listItems --query-file query.json

Debugging and Development

# Preview request without sending
mrapids run DeleteUser \
  --param id=123 \
  --dry-run

# Show as curl command
mrapids run DeleteUser \
  --param id=123 \
  --as-curl

# Trace HTTP traffic
mrapids run GetUser \
  --param id=123 \
  --trace \
  --verbose

# Replay last successful request
mrapids run GetUser --replay-last

🎓 Pro Tips

1. Use Environment-Specific Configs

# Development with verbose output
mrapids run GetUser --env dev --verbose

# Production with specific profile
mrapids run GetUser --env prod --profile prod-readonly

2. Chain Operations with Collections

# .mrapids/collections/user_flow.yaml
requests:
  - name: Create User
    operation: CreateUser
    save_as: user
  
  - name: Add Payment Method
    operation: AddPaymentMethod
    params:
      user_id: "{{ user.id }}"
    depends_on: ["Create User"]

3. Interactive Mode for Complex Requests

# Generate minimal template
mrapids run ComplexOperation -i --minimal

# Generate full template with all fields
mrapids run ComplexOperation -i --full

4. Always Validate Before Production

# Dry run first
mrapids run DeleteUser --param id=123 --dry-run

# Check as curl
mrapids run DeleteUser --param id=123 --as-curl

# Validate spec changes
mrapids diff old.yaml new.yaml --breaking-only

5. Set Up Proper Authentication Profiles

# Create profile for each environment
cat > .mrapids/auth/prod.toml << EOF
[profile]
name = "production"
type = "bearer"

[auth]
token_env = "PROD_API_TOKEN"
EOF

# Use environment-specific profiles
mrapids run GetUser --env production --profile prod

🔗 Supported Formats

Universal API Specification Support

  • Swagger 2.0 - Classic format, widely used
  • OpenAPI 3.0 - Modern standard with rich features
  • OpenAPI 3.1 - Latest version with JSON Schema compatibility
  • JSON and YAML - Both file formats supported
  • Local files and URLs - Load from disk or internet

🚀 Next Steps

Ready to start using MicroRapid?

Begin by initializing your first API project:

mrapids init your-api --from-url https://your-api.com/openapi.json

Need help? Check our Quick Start Guide or Documentation.