Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python-schema-match/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Python Schema Match
# Python Schema Match

A sample HTTP server application designed to test and validate JSON schema matching capabilities with Keploy. This application serves multiple diverse endpoints with various response schemas to comprehensively test schema structure validation and compatibility.

Expand Down
28 changes: 27 additions & 1 deletion python-schema-match/app-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,32 @@
# 10. PASS: Exact match
'/edge/nested_null': {
"data": {"value": None}
},

# 11. FAIL: Complex User (Type mismatch + Missing nested key)
'/complex/user': {
"id": "500", # FAIL: Expected int, got string
"name": "Jane Doe",
"contact": {
"email": "jane@example.com"
# FAIL: Missing "phone" key
},
"tags": ["vip", "early-adopter"],
"metadata": {
"created_at": "2023-01-01T00:00:00Z",
"login_count": 42
}
},

# 12. FAIL: Complex Product (Array item mismatch)
'/complex/product': {
"sku": "XYZ-999",
"specs": [
{"key": "weight", "value": "1.5kg", "unit": "kg"}, # FAIL: value expected float, got string
{"key": "warranty", "value": 2, "unit": "years"}
],
"in_stock": True,
"dimensions": [10, "20", 5.5] # FAIL: 2nd element expected int/float, got string
}
}

Expand Down Expand Up @@ -127,7 +153,7 @@ def handle_request(client_socket):
else:
body = json.dumps(body_data)

response = f"HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nContent-Length: {len(body)}\r\n\r\n{body}"
response = f"HTTP/1.0 200 OK\r\nContent-Type: application/json\r\nContent-Length: {len(body)}\r\nConnection: close\r\n\r\n{body}"
client_socket.sendall(response.encode('utf-8'))

except Exception as e:
Expand Down
22 changes: 22 additions & 0 deletions python-schema-match/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@
# Added 10th endpoint for clean 7/3 split
Comment thread
Sarthak160 marked this conversation as resolved.
'/edge/nested_null': {
"data": {"value": None}
},
'/complex/user': {
"id": 500,
"name": "Jane Doe",
"contact": {
"email": "jane@example.com",
"phone": {"home": "555-0123", "mobile": "555-0987"}
},
"tags": ["vip", "early-adopter"],
"metadata": {
"created_at": "2023-01-01T00:00:00Z",
"login_count": 42
}
},
'/complex/product': {
"sku": "XYZ-999",
"specs": [
{"key": "weight", "value": 1.5, "unit": "kg"},
{"key": "warranty", "value": 2, "unit": "years"}
],
"in_stock": True,
"dimensions": [10, 20, 5.5]
}
}

Expand Down
4 changes: 3 additions & 1 deletion python-schema-match/check-endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
'/edge/empty_response',
'/edge/null_root',
'/edge/special_chars',
'/edge/nested_null'
'/edge/nested_null',
'/complex/user',
'/complex/product'
]

def check_endpoints():
Expand Down