Skip to content

Commit f219c82

Browse files
committed
fix: auto-regenerate OpenAPI spec on push to main
The CI check only ran on PRs, so direct pushes to main silently drifted the spec. This caused the fetchOrderBook side parameter (added in v2.37.0) to never reach the MCP or SDKs.
1 parent 092d140 commit f219c82

6 files changed

Lines changed: 103 additions & 8 deletions

File tree

‎.github/workflows/openapi-check.yml‎

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@ on:
44
pull_request:
55
paths:
66
- 'core/src/BaseExchange.ts'
7+
- 'core/src/types.ts'
8+
- 'core/src/router/types.ts'
9+
- 'core/src/utils/math.ts'
10+
- 'core/src/server/exchange-factory.ts'
11+
- 'core/scripts/generate-openapi.js'
712
- '.github/workflows/openapi-check.yml'
13+
push:
14+
branches: [main]
15+
paths:
16+
- 'core/src/BaseExchange.ts'
17+
- 'core/src/types.ts'
18+
- 'core/src/router/types.ts'
19+
- 'core/src/utils/math.ts'
20+
- 'core/src/server/exchange-factory.ts'
21+
- 'core/scripts/generate-openapi.js'
822

923
jobs:
1024
verify-spec:
1125
name: Verify OpenAPI spec is up-to-date
26+
if: github.event_name == 'pull_request'
1227
runs-on: ubuntu-latest
1328
steps:
1429
- uses: actions/checkout@v4
@@ -25,10 +40,43 @@ jobs:
2540

2641
- name: Check if spec changed
2742
run: |
28-
if git diff --exit-code core/src/server/openapi.yaml; then
29-
echo "✓ OpenAPI spec is up-to-date"
43+
if git diff --exit-code core/src/server/openapi.yaml core/src/server/method-verbs.json; then
44+
echo "OpenAPI spec is up-to-date"
3045
else
31-
echo "✗ OpenAPI spec is out of sync with BaseExchange.ts"
46+
echo "OpenAPI spec is out of sync with source files"
3247
echo "Run: npm run generate:openapi --workspace=pmxt-core"
3348
exit 1
3449
fi
50+
51+
auto-regenerate:
52+
name: Auto-regenerate OpenAPI spec
53+
if: github.event_name == 'push'
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: write
57+
steps:
58+
- uses: actions/checkout@v4
59+
with:
60+
ref: main
61+
62+
- uses: actions/setup-node@v4
63+
with:
64+
node-version: '20'
65+
66+
- name: Install dependencies
67+
run: npm install --workspace=pmxt-core
68+
69+
- name: Regenerate OpenAPI spec
70+
run: npm run generate:openapi --workspace=pmxt-core
71+
72+
- name: Commit if changed
73+
run: |
74+
git config user.name "github-actions[bot]"
75+
git config user.email "github-actions[bot]@users.noreply.github.com"
76+
git add core/src/server/openapi.yaml core/src/server/method-verbs.json
77+
if ! git diff --cached --quiet; then
78+
git commit -m "chore: auto-regenerate OpenAPI spec"
79+
git push origin main
80+
else
81+
echo "OpenAPI spec is already up-to-date"
82+
fi

‎.github/workflows/publish.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ jobs:
6464
- name: Fetch OpenAPI Specs
6565
run: npm run fetch:openapi --workspace=pmxt-core
6666

67+
- name: Regenerate OpenAPI spec
68+
run: npm run generate:openapi --workspace=pmxt-core
69+
6770
- name: Generate SDKs
6871
run: npm run generate:sdk:all --workspace=pmxt-core
6972

‎changelog.md‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,33 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [2.37.5] - 2026-05-04
6+
7+
### Fix: OpenAPI spec not auto-regenerated on direct pushes to main
8+
9+
- The CI check for OpenAPI spec drift only ran on pull requests. Direct
10+
pushes to main bypassed the check entirely, allowing the spec (and
11+
downstream MCP + SDKs) to silently drift from `BaseExchange.ts`.
12+
- The `openapi-check` workflow now auto-regenerates and commits the
13+
sidecar spec on push to main. The PR check-and-fail behavior is
14+
unchanged.
15+
- The path trigger now watches all source files the generator reads
16+
(`types.ts`, `router/types.ts`, `math.ts`, `exchange-factory.ts`),
17+
not just `BaseExchange.ts`.
18+
- The publish workflow now runs `generate:openapi` before SDK generation
19+
as a safety net.
20+
21+
### Fix: `fetchOrderBook` `side` parameter missing from OpenAPI spec
22+
23+
- The optional `side` parameter added in v2.37.0 was never propagated to
24+
the OpenAPI spec because the commit was pushed directly to main
25+
(bypassing the PR-only CI check above).
26+
- The `paramKind` classifier in `generate-openapi.js` did not recognize
27+
string literal unions (`'yes' | 'no'`), causing methods with such
28+
parameters to incorrectly flip from GET to POST. String literal unions
29+
are now classified as `string`, keeping `fetchOrderBook` as GET with
30+
`side` as a query parameter.
31+
532
## [2.37.4] - 2026-05-03
633

734
### Fix: Polymarket `fetchOrderBook` returns `timestamp: null`

‎core/scripts/generate-openapi.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,17 +1221,24 @@ function paramKind(typeNode) {
12211221
case ts.SyntaxKind.TypeLiteral:
12221222
return 'object';
12231223
case ts.SyntaxKind.UnionType: {
1224-
// Allow unions of named object types as object-kind (fetchTrades
1225-
// takes `TradesParams | HistoryFilterParams`, etc.). Reject other
1226-
// unions as unknown so we fall back to POST.
12271224
const members = typeNode.types.filter(
12281225
t =>
12291226
t.kind !== ts.SyntaxKind.NullKeyword &&
12301227
t.kind !== ts.SyntaxKind.UndefinedKeyword
12311228
);
1229+
// Union of named object types → object-kind (fetchTrades takes
1230+
// `TradesParams | HistoryFilterParams`, etc.)
12321231
if (members.every(t => t.kind === ts.SyntaxKind.TypeReference)) {
12331232
return 'object';
12341233
}
1234+
// Union of string literals → string-kind (fetchOrderBook takes
1235+
// `side?: 'yes' | 'no'`). These serialize as query params fine.
1236+
if (members.every(t =>
1237+
t.kind === ts.SyntaxKind.LiteralType &&
1238+
t.literal.kind === ts.SyntaxKind.StringLiteral
1239+
)) {
1240+
return 'string';
1241+
}
12351242
return 'unknown';
12361243
}
12371244
default:

‎core/src/server/method-verbs.json‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
"name": "id",
9292
"kind": "string",
9393
"optional": false
94+
},
95+
{
96+
"name": "side",
97+
"kind": "string",
98+
"optional": true
9499
}
95100
]
96101
},
@@ -229,7 +234,7 @@
229234
},
230235
{
231236
"name": "side",
232-
"kind": "unknown",
237+
"kind": "string",
233238
"optional": false
234239
},
235240
{
@@ -249,7 +254,7 @@
249254
},
250255
{
251256
"name": "side",
252-
"kind": "unknown",
257+
"kind": "string",
253258
"optional": false
254259
},
255260
{

‎core/src/server/openapi.yaml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,11 @@ paths:
640640
required: true
641641
schema:
642642
type: string
643+
- in: query
644+
name: side
645+
required: false
646+
schema:
647+
type: string
643648
responses:
644649
'200':
645650
description: Fetch Order Book response

0 commit comments

Comments
 (0)