api-mocker 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {api_mocker-0.3.0/src/api_mocker.egg-info → api_mocker-0.4.0}/PKG-INFO +2 -2
- {api_mocker-0.3.0 → api_mocker-0.4.0}/pyproject.toml +2 -2
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/cli.py +128 -1
- api_mocker-0.4.0/src/api_mocker/mock_responses.py +622 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0/src/api_mocker.egg-info}/PKG-INFO +2 -2
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker.egg-info/SOURCES.txt +3 -1
- api_mocker-0.4.0/tests/test_mock_responses.py +737 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/LICENSE +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/PYPI_DESCRIPTION.md +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/README.md +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/setup.cfg +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/__init__.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/advanced.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/ai_generator.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/analytics.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/config.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/core.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/dashboard.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/enhanced_analytics.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/openapi.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/plugins.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/recorder.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/scenarios.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/server.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/smart_matching.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker/testing.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker.egg-info/dependency_links.txt +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker.egg-info/entry_points.txt +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker.egg-info/requires.txt +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/src/api_mocker.egg-info/top_level.txt +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/tests/test_basic.py +0 -0
- {api_mocker-0.3.0 → api_mocker-0.4.0}/tests/test_core.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: api-mocker
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: 🚀 The Ultimate API Development Acceleration Tool - 3000+ Downloads! Production-ready FastAPI mock server with AI-powered generation, scenario-based mocking, smart response matching, enhanced analytics,
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: 🚀 The Ultimate API Development Acceleration Tool - 3000+ Downloads! Production-ready FastAPI mock server with AI-powered generation, scenario-based mocking, smart response matching, enhanced analytics, comprehensive testing framework, and advanced mock response management system.
|
|
5
5
|
Author-email: sherin joseph roy <sherin.joseph2217@gmail.com>
|
|
6
6
|
License: MIT License
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "api-mocker"
|
|
3
|
-
version = "0.
|
|
4
|
-
description = "🚀 The Ultimate API Development Acceleration Tool - 3000+ Downloads! Production-ready FastAPI mock server with AI-powered generation, scenario-based mocking, smart response matching, enhanced analytics,
|
|
3
|
+
version = "0.4.0"
|
|
4
|
+
description = "🚀 The Ultimate API Development Acceleration Tool - 3000+ Downloads! Production-ready FastAPI mock server with AI-powered generation, scenario-based mocking, smart response matching, enhanced analytics, comprehensive testing framework, and advanced mock response management system."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "sherin joseph roy", email = "sherin.joseph2217@gmail.com" }
|
|
7
7
|
]
|
|
@@ -16,7 +16,8 @@ from api_mocker.dashboard import DashboardManager
|
|
|
16
16
|
from api_mocker.advanced import AdvancedFeatures, RateLimitConfig, CacheConfig, AuthConfig
|
|
17
17
|
from api_mocker.scenarios import scenario_manager, Scenario, ScenarioCondition, ScenarioResponse, ScenarioType
|
|
18
18
|
from api_mocker.smart_matching import smart_matcher, ResponseRule, MatchCondition, MatchType
|
|
19
|
-
from api_mocker.enhanced_analytics import EnhancedAnalytics
|
|
19
|
+
from api_mocker.enhanced_analytics import EnhancedAnalytics
|
|
20
|
+
from api_mocker.mock_responses import MockSet, MockAPIResponse, ResponseType, HTTPMethod, create_user_response, create_error_response, create_delayed_response
|
|
20
21
|
|
|
21
22
|
app = typer.Typer(help="api-mocker: The industry-standard, production-ready, free API mocking and development acceleration tool.")
|
|
22
23
|
console = Console()
|
|
@@ -1306,5 +1307,131 @@ def enhanced_analytics(
|
|
|
1306
1307
|
raise typer.Exit(1)
|
|
1307
1308
|
|
|
1308
1309
|
|
|
1310
|
+
@app.command()
|
|
1311
|
+
def mock_responses(
|
|
1312
|
+
action: str = typer.Argument(..., help="Mock response action (create, list, find, test, export, import)"),
|
|
1313
|
+
name: str = typer.Option(None, "--name", "-n", help="Response name"),
|
|
1314
|
+
path: str = typer.Option(None, "--path", "-p", help="Response path"),
|
|
1315
|
+
method: str = typer.Option("GET", "--method", "-m", help="HTTP method"),
|
|
1316
|
+
status_code: int = typer.Option(200, "--status", "-s", help="Status code"),
|
|
1317
|
+
response_type: str = typer.Option("static", "--type", "-t", help="Response type (static, dynamic, templated, conditional, delayed, error)"),
|
|
1318
|
+
file: str = typer.Option(None, "--file", "-f", help="Configuration file"),
|
|
1319
|
+
output: str = typer.Option(None, "--output", "-o", help="Output file")
|
|
1320
|
+
):
|
|
1321
|
+
"""Manage mock API responses with advanced features."""
|
|
1322
|
+
|
|
1323
|
+
if action == "create":
|
|
1324
|
+
if not name or not path:
|
|
1325
|
+
console.print("❌ Name and path are required for creating responses")
|
|
1326
|
+
raise typer.Exit(1)
|
|
1327
|
+
|
|
1328
|
+
# Create mock response based on type
|
|
1329
|
+
if response_type == "static":
|
|
1330
|
+
response = MockAPIResponse(
|
|
1331
|
+
path=path,
|
|
1332
|
+
method=HTTPMethod(method),
|
|
1333
|
+
status_code=status_code,
|
|
1334
|
+
name=name,
|
|
1335
|
+
response_type=ResponseType.STATIC,
|
|
1336
|
+
body={"message": "Static response"}
|
|
1337
|
+
)
|
|
1338
|
+
elif response_type == "templated":
|
|
1339
|
+
response = MockAPIResponse(
|
|
1340
|
+
path=path,
|
|
1341
|
+
method=HTTPMethod(method),
|
|
1342
|
+
status_code=status_code,
|
|
1343
|
+
name=name,
|
|
1344
|
+
response_type=ResponseType.TEMPLATED,
|
|
1345
|
+
template_vars={"id": "123", "name": "John Doe"},
|
|
1346
|
+
body={"id": "{{id}}", "name": "{{name}}"}
|
|
1347
|
+
)
|
|
1348
|
+
elif response_type == "delayed":
|
|
1349
|
+
response = MockAPIResponse(
|
|
1350
|
+
path=path,
|
|
1351
|
+
method=HTTPMethod(method),
|
|
1352
|
+
status_code=status_code,
|
|
1353
|
+
name=name,
|
|
1354
|
+
response_type=ResponseType.DELAYED,
|
|
1355
|
+
delay_ms=1000,
|
|
1356
|
+
body={"message": "Delayed response"}
|
|
1357
|
+
)
|
|
1358
|
+
elif response_type == "error":
|
|
1359
|
+
response = MockAPIResponse(
|
|
1360
|
+
path=path,
|
|
1361
|
+
method=HTTPMethod(method),
|
|
1362
|
+
status_code=500,
|
|
1363
|
+
name=name,
|
|
1364
|
+
response_type=ResponseType.ERROR,
|
|
1365
|
+
error_probability=1.0,
|
|
1366
|
+
body={"error": "Simulated error"}
|
|
1367
|
+
)
|
|
1368
|
+
else:
|
|
1369
|
+
response = create_user_response("123", "John Doe")
|
|
1370
|
+
response.name = name
|
|
1371
|
+
response.path = path
|
|
1372
|
+
response.method = HTTPMethod(method)
|
|
1373
|
+
response.status_code = status_code
|
|
1374
|
+
|
|
1375
|
+
console.print(f"✅ Created mock response: {name}")
|
|
1376
|
+
|
|
1377
|
+
elif action == "list":
|
|
1378
|
+
# This would typically load from a file or database
|
|
1379
|
+
console.print("📋 Available mock responses:")
|
|
1380
|
+
console.print(" (Use 'create' to add responses)")
|
|
1381
|
+
|
|
1382
|
+
elif action == "find":
|
|
1383
|
+
if not path:
|
|
1384
|
+
console.print("❌ Path is required for finding responses")
|
|
1385
|
+
raise typer.Exit(1)
|
|
1386
|
+
|
|
1387
|
+
# Simulate finding responses
|
|
1388
|
+
console.print(f"🔍 Searching for responses matching: {path}")
|
|
1389
|
+
console.print(" (Use 'create' to add responses first)")
|
|
1390
|
+
|
|
1391
|
+
elif action == "test":
|
|
1392
|
+
if not path:
|
|
1393
|
+
console.print("❌ Path is required for testing responses")
|
|
1394
|
+
raise typer.Exit(1)
|
|
1395
|
+
|
|
1396
|
+
# Create a test response and test it
|
|
1397
|
+
test_response = create_user_response("123", "John Doe")
|
|
1398
|
+
test_response.path = path
|
|
1399
|
+
test_response.method = HTTPMethod(method)
|
|
1400
|
+
|
|
1401
|
+
result = test_response.generate_response()
|
|
1402
|
+
console.print(f"🧪 Test response for {path}:")
|
|
1403
|
+
console.print(f" Status: {result['status_code']}")
|
|
1404
|
+
console.print(f" Body: {result['body']}")
|
|
1405
|
+
|
|
1406
|
+
elif action == "export":
|
|
1407
|
+
if not output:
|
|
1408
|
+
output = f"mock_responses_{int(time.time())}.yaml"
|
|
1409
|
+
|
|
1410
|
+
# Create a sample mock set and export it
|
|
1411
|
+
mock_set = MockSet("sample_mocks")
|
|
1412
|
+
mock_set.add_response(create_user_response("123", "John Doe"))
|
|
1413
|
+
mock_set.add_response(create_error_response(404, "Not found"))
|
|
1414
|
+
mock_set.add_response(create_delayed_response(1000))
|
|
1415
|
+
|
|
1416
|
+
mock_set.save_to_file(output)
|
|
1417
|
+
console.print(f"✅ Mock responses exported to {output}")
|
|
1418
|
+
|
|
1419
|
+
elif action == "import":
|
|
1420
|
+
if not file:
|
|
1421
|
+
console.print("❌ File is required for importing responses")
|
|
1422
|
+
raise typer.Exit(1)
|
|
1423
|
+
|
|
1424
|
+
try:
|
|
1425
|
+
mock_set = MockSet.load_from_file(file)
|
|
1426
|
+
console.print(f"✅ Imported {len(mock_set.responses)} responses from {file}")
|
|
1427
|
+
except Exception as e:
|
|
1428
|
+
console.print(f"❌ Error importing from {file}: {e}")
|
|
1429
|
+
raise typer.Exit(1)
|
|
1430
|
+
|
|
1431
|
+
else:
|
|
1432
|
+
console.print(f"❌ Unknown action: {action}")
|
|
1433
|
+
raise typer.Exit(1)
|
|
1434
|
+
|
|
1435
|
+
|
|
1309
1436
|
if __name__ == "__main__":
|
|
1310
1437
|
app()
|