mrapids 0.1.31

Your OpenAPI, but executable
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# MicroRapid CLI Command Guide

> **Quick Reference for Developers, DevOps, and QA Engineers**

## 🚀 Quick Start Commands

### For First-Time Users
```bash
# Start a new project from scratch
mrapids init my-api-project

# Or initialize from an existing OpenAPI spec
mrapids init my-api --from-url https://api.example.com/openapi.json

# Analyze what's in your spec
mrapids analyze openapi.yaml

# Run your first API call
mrapids run openapi.yaml --operation getUser --dry-run
```

## 📚 Commands by Use Case

### 🏗️ Project Setup & Configuration

#### `init` - Start a New Project
**When to use**: Starting a new API project or importing existing specs
```bash
# Create from template
mrapids init my-project --template rest

# Import from URL
mrapids init my-project --from-url https://petstore.swagger.io/v2/swagger.json

# Force overwrite existing
mrapids init my-project --force
```
**Output**: Creates project structure with OpenAPI spec, examples, and config files

#### `init-config` - Set Up Environment Configuration
**When to use**: Configuring different environments (dev, staging, prod)
```bash
# Interactive setup
mrapids init-config

# Create specific environment
mrapids init-config --env production --base-url https://api.prod.com

# With authentication
mrapids init-config --env staging --profile staging-key
```
**Output**: Creates `.mrapids/config/[env].yaml` with environment-specific settings

### 🔍 API Discovery & Analysis

#### `analyze` - Generate Examples from Your Spec
**When to use**: Understanding your API structure and generating test data
```bash
# Basic analysis
mrapids analyze openapi.yaml

# Generate examples in specific directory
mrapids analyze openapi.yaml --output ./test-data

# Skip validation for draft specs
mrapids analyze openapi.yaml --skip-validate
```
**Output**: Creates example requests/responses for every operation

#### `list` - Browse Available Operations
**When to use**: Quick overview of what's in your API
```bash
# List all operations
mrapids list operations openapi.yaml

# Filter by method
mrapids list operations openapi.yaml --method GET

# Filter by path pattern
mrapids list operations openapi.yaml --pattern "/users/*"

# List saved requests
mrapids list requests
```
**Output**: Table of operations with IDs, methods, and paths

#### `show` - Get Operation Details
**When to use**: Deep dive into a specific endpoint
```bash
# Show operation details
mrapids show getUserById --spec openapi.yaml

# Include schema information
mrapids show createUser --spec openapi.yaml --verbose

# Output as JSON
mrapids show getOrders --spec openapi.yaml --format json
```
**Output**: Parameters, request body schema, response schemas, and examples

#### `explore` - Search Operations
**When to use**: Finding operations when you don't know exact names
```bash
# Search by keyword
mrapids explore user --spec openapi.yaml

# Case-sensitive search
mrapids explore Order --case-sensitive

# Search in descriptions too
mrapids explore payment --include-descriptions
```
**Output**: Filtered list of matching operations

### 🏃 API Execution & Testing

#### `run` - Execute API Operations
**When to use**: Making actual API calls during development or debugging
```bash
# Dry run (see what would be sent)
mrapids run openapi.yaml --operation getUser --dry-run

# With parameters
mrapids run openapi.yaml --operation getUserById --param userId=123

# With request body
mrapids run openapi.yaml --operation createUser --body user.json

# Using saved request
mrapids run openapi.yaml --request saved-requests/create-user.yaml

# With specific environment
mrapids run openapi.yaml --operation listOrders --env production
```
**Output**: API response with status code and formatted body

#### `test` - Run API Tests
**When to use**: Validating API behavior and contracts
```bash
# Test single operation
mrapids test openapi.yaml --operation getHealth

# Test all operations
mrapids test openapi.yaml --all

# With test data
mrapids test openapi.yaml --operation createUser --data test-user.json

# Validate responses against schema
mrapids test openapi.yaml --operation getUser --validate-response

# Performance test
mrapids test openapi.yaml --operation search --iterations 100 --concurrent 10
```
**Output**: Test results with pass/fail status and timing

#### `setup-tests` - Generate Complete Test Suite
**When to use**: Setting up automated testing for CI/CD
```bash
# Generate test structure
mrapids setup-tests openapi.yaml

# For specific framework
mrapids setup-tests openapi.yaml --framework pytest

# With CI/CD config
mrapids setup-tests openapi.yaml --with-ci github-actions
```
**Output**: Test files, fixtures, and CI configuration

### 🔐 Authentication Management

#### `auth` - Manage Authentication
**When to use**: Setting up API authentication for different environments
```bash
# OAuth flow
mrapids auth login github
mrapids auth login google --scopes "read:user,repo"

# API key setup
mrapids auth add-key production --header "X-API-Key"

# List profiles
mrapids auth list

# Test authentication
mrapids auth test production-oauth

# Remove profile
mrapids auth logout github
```
**Output**: Encrypted auth profiles in `.mrapids/auth/`

### 🛠️ Development Tools

#### `generate` - Code Generation
**When to use**: Creating boilerplate code from specs
```bash
# Generate models
mrapids generate models openapi.yaml --language typescript

# Generate API client
mrapids generate client openapi.yaml --language python --output ./client

# Generate server stubs
mrapids generate server openapi.yaml --framework express
```
**Output**: Generated code files in target language

#### `sdk` - Generate Full SDK
**When to use**: Creating client libraries for API consumers
```bash
# TypeScript SDK
mrapids sdk openapi.yaml --language typescript --package-name @mycompany/api

# Python SDK with docs
mrapids sdk openapi.yaml --language python --with-docs

# Multiple languages
mrapids sdk openapi.yaml --language typescript,python,go,rust

# With custom templates
mrapids sdk openapi.yaml --template ./my-templates --language java
```
**Output**: Complete SDK with package files, docs, and examples

#### `validate` - Validate OpenAPI Spec
**When to use**: Ensuring spec correctness before deployment
```bash
# Basic validation
mrapids validate openapi.yaml

# Strict mode (warnings as errors)
mrapids validate openapi.yaml --strict

# With custom rules
mrapids validate openapi.yaml --rules security-rules.yaml

# Multiple specs
mrapids validate api-v1.yaml api-v2.yaml --format json
```
**Output**: Validation report with errors and warnings

### 📋 API Maintenance

#### `diff` - Compare API Versions
**When to use**: Finding breaking changes between versions
```bash
# Compare two specs
mrapids diff api-v1.yaml api-v2.yaml

# Only breaking changes
mrapids diff api-old.yaml api-new.yaml --breaking-only

# Ignore certain changes
mrapids diff api-v1.yaml api-v2.yaml --ignore-descriptions

# Output as JSON
mrapids diff api-v1.yaml api-v2.yaml --format json
```
**Output**: List of changes categorized by severity

#### `flatten` - Simplify Complex Specs
**When to use**: Creating a single-file spec from multi-file refs
```bash
# Flatten all $ref
mrapids flatten openapi.yaml --output openapi-flat.yaml

# Keep internal refs
mrapids flatten openapi.yaml --external-only

# Validate after flattening
mrapids flatten openapi.yaml --validate
```
**Output**: Single OpenAPI file with all references resolved

#### `resolve` - Resolve References
**When to use**: Debugging reference issues or preparing for tools that don't support $ref
```bash
# Resolve and show
mrapids resolve openapi.yaml

# Resolve specific path
mrapids resolve openapi.yaml --path "#/components/schemas/User"

# Save resolved spec
mrapids resolve openapi.yaml --output resolved.yaml
```
**Output**: Spec with all references replaced by actual content

#### `cleanup` - Clean Temporary Files
**When to use**: Cleaning up after testing or when switching projects
```bash
# Clean test artifacts
mrapids cleanup

# Clean specific types
mrapids cleanup --cache --temp --logs

# Clean everything except config
mrapids cleanup --all --keep-config

# Dry run
mrapids cleanup --dry-run
```
**Output**: List of removed files and freed space

## 🎯 Common Workflows

### For Developers
```bash
# Morning routine
mrapids validate openapi.yaml
mrapids diff openapi.yaml openapi-prod.yaml
mrapids test openapi.yaml --operation healthCheck

# Adding new endpoint
mrapids analyze openapi.yaml
mrapids run openapi.yaml --operation newEndpoint --dry-run
mrapids generate client openapi.yaml --language typescript

# Debugging
mrapids show failingOperation --spec openapi.yaml --verbose
mrapids run openapi.yaml --operation failingOperation --curl-output
```

### For DevOps
```bash
# CI/CD Pipeline
mrapids validate openapi.yaml --strict
mrapids test openapi.yaml --all --env staging
mrapids diff openapi-previous.yaml openapi.yaml --breaking-only

# Environment setup
mrapids init-config --env production --no-interactive
mrapids auth add-key production --from-env API_KEY
mrapids test openapi.yaml --env production --operation health

# Monitoring
mrapids run openapi.yaml --operation metrics --format json | jq .
```

### For QA Engineers
```bash
# Test suite setup
mrapids setup-tests openapi.yaml --framework pytest
mrapids analyze openapi.yaml --output test-data/

# Contract testing
mrapids validate openapi.yaml
mrapids test openapi.yaml --all --validate-response

# Regression testing
mrapids diff api-v1.yaml api-v2.yaml > breaking-changes.txt
mrapids test api-v2.yaml --from-file regression-tests.yaml

# Load testing
mrapids test openapi.yaml --operation search \
  --iterations 1000 --concurrent 50 --duration 5m
```

## 💡 Pro Tips

### 1. **Use Aliases for Common Commands**
```bash
alias mr='mrapids'
alias mrt='mrapids test'
alias mrr='mrapids run'
```

### 2. **Chain Commands for Workflows**
```bash
# Validate, test, and deploy
mrapids validate api.yaml && \
mrapids test api.yaml --all && \
echo "Ready to deploy!"
```

### 3. **Use Environment Variables**
```bash
export MRAPIDS_SPEC=./openapi.yaml
export MRAPIDS_ENV=staging
mrapids run --operation getUser  # Uses env vars
```

### 4. **Output Formats for Automation**
```bash
# JSON for parsing
mrapids list operations api.yaml --format json | jq '.operations[].id'

# CSV for reports
mrapids diff v1.yaml v2.yaml --format csv > changes.csv
```

### 5. **Dry Run Everything First**
```bash
# Always safe
mrapids run api.yaml --operation deleteUser --dry-run
mrapids cleanup --dry-run
```

## 🆘 Getting Help

```bash
# General help
mrapids --help
mrapids help

# Command-specific help
mrapids run --help
mrapids test --help

# Show version
mrapids --version
```

## 🔗 See Also

- [API Documentation]./API_REFERENCE.md
- [Configuration Guide]./CONFIGURATION.md
- [CI/CD Integration]./CI_CD_GUIDE.md
- [Troubleshooting]./TROUBLESHOOTING.md

---

*Remember: MicroRapid executes your OpenAPI specs directly - no conversion needed! Your spec IS your test.*