forked from Soroban-Pulse/SorobanPulse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_openapi.py
More file actions
39 lines (36 loc) · 2.09 KB
/
fix_openapi.py
File metadata and controls
39 lines (36 loc) · 2.09 KB
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
with open('src/handlers.rs', 'r') as f:
c = f.read()
# 1. get_events OpenAPI macro
c = c.replace(
""" ("topic_sym" = Option<String>, Query, description = "Filter by top-level topic symbol (from topic 0)"),
("search" = Option<String>, Query, description = "Full-text search on normalized event payload"),
),
responses(""",
""" ("topic_sym" = Option<String>, Query, description = "Filter by top-level topic symbol (from topic 0)"),
("search" = Option<String>, Query, description = "Full-text search on normalized event payload"),
("If-None-Match" = Option<String>, Header, description = "Conditional GET: Return 304 if ETag matches"),
),
responses(
(status = 304, description = "Not Modified (ETag matched)", headers(
("ETag" = String, description = "Computed ETag"),
("Cache-Control" = String, description = "No cache")
)),""")
# 2. get_events_by_contract OpenAPI macro
c = c.replace(
""" ("to_ledger" = Option<i64>, Query, description = "Return events at or before this ledger"),
("sort" = Option<String>, Query, description = "Sort order: asc (oldest first) or desc (newest first, default)"),
("sort_by" = Option<crate::models::SortBy>, Query, description = "Sort column: ledger (default), timestamp, or created_at"),
),
responses(""",
""" ("to_ledger" = Option<i64>, Query, description = "Return events at or before this ledger"),
("sort" = Option<String>, Query, description = "Sort order: asc (oldest first) or desc (newest first, default)"),
("sort_by" = Option<crate::models::SortBy>, Query, description = "Sort column: ledger (default), timestamp, or created_at"),
("If-None-Match" = Option<String>, Header, description = "Conditional GET: Return 304 if ETag matches"),
),
responses(
(status = 304, description = "Not Modified (ETag matched)", headers(
("ETag" = String, description = "Computed ETag"),
("Cache-Control" = String, description = "No cache")
)),""")
with open('src/handlers.rs', 'w') as f:
f.write(c)