Skip to content
Open
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
84 changes: 84 additions & 0 deletions tests/fixtures/xquik_openapi31.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"openapi": "3.1.0",
"info": {
"title": "Xquik API",
"version": "1.0",
"description": "REST API for X automation workflows"
},
"servers": [
{
"url": "https://xquik.com"
}
],
"security": [
{
"apiKey": []
}
],
"paths": {
"/api/v1/x/tweets/search": {
"get": {
"operationId": "searchTweets",
"summary": "Search Tweets",
"tags": ["x"],
"parameters": [
{
"name": "q",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Tweet search results",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TweetSearchResponse"
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"apiKey": {
"type": "apiKey",
"in": "header",
"name": "x-api-key"
}
},
"schemas": {
"TweetSearchResponse": {
"type": "object",
"required": ["tweets"],
"properties": {
"tweets": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tweet"
}
}
}
},
"Tweet": {
"type": "object",
"required": ["id", "text"],
"properties": {
"id": {
"type": "string"
},
"text": {
"type": "string"
}
}
}
}
}
}
19 changes: 19 additions & 0 deletions tests/unit/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,24 @@ def test_mock_api_generation():
pass


def test_xquik_openapi31_mock_api_generation(tmp_path):
spec_data = load_api_specification("tests/fixtures/xquik_openapi31.json")

output_dir = generate_mock_api(
spec_data=spec_data,
output_base_dir=tmp_path,
mock_server_name="xquik_api_mock",
auth_enabled=False,
webhooks_enabled=False,
admin_ui_enabled=False,
storage_enabled=False,
)

generated_main = (output_dir / "main.py").read_text(encoding="utf-8")
assert '@app.get("/api/v1/x/tweets/search", summary="Search Tweets")' in generated_main
assert "mock_get_api_v1_x_tweets_search" in generated_main
assert "#/components/schemas/TweetSearchResponse" in generated_main


if __name__ == "__main__":
test_mock_api_generation()