fix(api): correct openapi.yaml drift from actual v17 responses [BUG-112] - #227
fix(api): correct openapi.yaml drift from actual v17 responses [BUG-112]#227Morenikeoa wants to merge 1 commit into
Conversation
Four documentation drifts vs. the real implementation:
- /candles/{slab} (src/routes/candles.ts) was completely missing from
the spec despite being a live route.
- MarketWithStats/MarketStats document lastPrice/markPrice/indexPrice/
fundingRate/lastCrankSlot as string, but markets.ts returns them as
raw numeric DB columns (JS numbers) — confirmed against the existing
test mocks in markets.test.ts.
- FundingHistoryEntry.slot/priceE6 documented as string, but funding.ts
passes through h.slot/h.price_e6 unmodified — same numeric-column
pattern, confirmed against funding.test.ts mocks.
- MarketDetails.engine is documented as a non-nullable object, but
markets.ts explicitly returns engine: null for v17 market-group
accounts (engine state moved to per-portfolio, queried via
/markets/{slab}/stats instead).
No behavior change — openapi.yaml is served as-is from docs.ts and has
no associated runtime logic, so there's no test suite to update; verified
via `npx js-yaml openapi.yaml` (syntax) and a $ref-resolution check (all
81 refs resolve, including the new ones added here).
|
@Princessdada is attempting to deploy a commit to the Khubair Nasir's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 47 minutes and 24 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Independent verification — not an approval (QA/Security own that). I checked the corrected spec against the actual route rather than taking it on trust. It's accurate. A spec-only PR can't be mutation-tested, so I verified the claims directly against
No residual drift found. The (Method note on myself: my first pass grepped only the The one real gap: nothing stops it re-drifting
Cheapest guard that would actually bind — a test asserting the spec and the code agree on the enum: import { load } from "js-yaml";
const spec = load(readFileSync("openapi.yaml", "utf8")) as any;
const specEnum = spec.paths["/candles/{slab}"].get.parameters
.find((p: any) => p.name === "resolution").schema.enum;
expect(specEnum.sort()).toEqual(Object.keys(RES_TO_SECONDS).sort());That pins the one field most likely to drift (adding a resolution to Not blocking — the correction itself is right, and I'd take it as-is. Flagging because a spec fix without a drift guard tends to be the same fix again in three months. |
Bug
openapi.yamlhas drifted from the actual route implementations in four ways:/candles/{slab}(src/routes/candles.ts) is a live route with no entry in the spec at all.MarketWithStats/MarketStats:lastPrice/markPrice/indexPrice/fundingRate/lastCrankSlot(and snake_case equivalents) are documented asstring, butmarkets.tsreturns them as raw numeric Postgres columns — confirmed as JS numbers via the existing mocks intests/routes/markets.test.ts(e.g.last_price: 50000, not"50000").FundingHistoryEntry:slot/priceE6documented asstring, butfunding.tspasses throughh.slot/h.price_e6unmodified — same numeric-column pattern, confirmed viatests/routes/funding.test.tsmocks (e.g.slot: 123456789,price_e6: 50000000000).MarketDetails.engine: documented as a non-nullable object, butmarkets.tsexplicitly returnsengine: nullfor v17 market-group accounts (v17 engine state moved to per-portfolio storage, queried via/markets/{slab}/statsinstead) — anullhere is invalid against a non-nullableobjectschema for any strict validator or generated client.Fields that are genuinely large/precision-sensitive on-chain values stored as Postgres
numeric(totalOpenInterest,netLpPos,lpSumAbs, etc.) were left asstring— those really do come back as strings to avoid float precision loss, and were already documented correctly.Fix
/candles/{slab}path with a newCandlesResponseschema matching the route's actual TradingView-UDF-style response shape, and aCandlestag.MarketWithStatsandMarketStatsfromstringtonumber/integer(withnullable: truewhere the route can returnnull).FundingHistoryEntry.slottointegerand.priceE6tonumber.nullable: true+ an explanatory description toMarketDetails.engine.Test plan
This is a documentation-only change to a static YAML file served as-is by
docs.ts— there's no associated runtime logic or existing test suite to update/revert-and-confirm against. Verified instead via:npx js-yaml openapi.yaml— parses cleanly, no syntax errors.$refin the parsed document and confirm it resolves — all 81 refs (including the new ones added here) resolve correctly.markets.test.ts,funding.test.ts) before changing its documented type.adl.test.ts);tsc --noEmitclean (expected, since this PR touches no.tsfiles).