Skip to content

Commit b71ea84

Browse files
committed
feat(openapi): generate checked-in MCP/Python contract types (#37 phase 2)
Implements phase 2 of #37 / closes #46. Generated artifacts are a contract reference; hand-written MCP/SDK public models are unchanged (no runtime or package behavior change — backward compatible). - MCP/TS: `openapi-typescript@7.4.4` (pinned devDep) -> checked-in packages/mcp/src/generated/openapi.d.ts; `npm run gen:openapi` regenerates. - Python SDK: `datamodel-code-generator==0.26.3` (pinned dev extra) -> checked-in packages/python-sdk/qveris/generated/openapi_models.py (pydantic v2, py3.8 target) + package __init__ documenting regeneration. - CI: .github/workflows/openapi-types.yml regenerates both with the pinned generators and fails on `git diff --exit-code`, path-scoped to docs/openapi/** + the generators (mirrors openapi-contract.yml from #44). Verified: artifacts are byte-reproducible from the checked-in spec (empty diff on regen), the .d.ts typechecks under tsc --strict, and the Python models pass py_compile.
1 parent 116775d commit b71ea84

6 files changed

Lines changed: 2778 additions & 5 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: OpenAPI generated types
2+
3+
# Issue #37 phase 2: the checked-in generated artifacts must be reproducible
4+
# from docs/openapi/qveris-public-api.openapi.json. Regenerate with the pinned
5+
# generators and fail if the working tree differs (contract / generator drift).
6+
7+
on:
8+
pull_request:
9+
paths:
10+
- "docs/openapi/**"
11+
- "packages/mcp/src/generated/**"
12+
- "packages/python-sdk/qveris/generated/**"
13+
- "packages/mcp/package.json"
14+
- "packages/python-sdk/pyproject.toml"
15+
- ".github/workflows/openapi-types.yml"
16+
push:
17+
branches:
18+
- main
19+
paths:
20+
- "docs/openapi/**"
21+
- "packages/mcp/src/generated/**"
22+
- "packages/python-sdk/qveris/generated/**"
23+
- "packages/mcp/package.json"
24+
- "packages/python-sdk/pyproject.toml"
25+
- ".github/workflows/openapi-types.yml"
26+
27+
permissions:
28+
contents: read
29+
30+
jobs:
31+
regen-and-diff:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 20
41+
42+
- name: Setup Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.11"
46+
47+
- name: Regenerate MCP TypeScript types
48+
run: npx --yes openapi-typescript@7.4.4 docs/openapi/qveris-public-api.openapi.json -o packages/mcp/src/generated/openapi.d.ts
49+
50+
- name: Regenerate Python SDK models
51+
run: |
52+
python -m pip install --quiet "datamodel-code-generator==0.26.3"
53+
python -m datamodel_code_generator \
54+
--input docs/openapi/qveris-public-api.openapi.json \
55+
--input-file-type openapi \
56+
--output packages/python-sdk/qveris/generated/openapi_models.py \
57+
--output-model-type pydantic_v2.BaseModel \
58+
--target-python-version 3.8 \
59+
--use-schema-description \
60+
--disable-timestamp
61+
62+
- name: Fail on drift
63+
run: |
64+
if ! git diff --exit-code -- \
65+
packages/mcp/src/generated/openapi.d.ts \
66+
packages/python-sdk/qveris/generated/openapi_models.py; then
67+
echo "::error::Generated OpenAPI artifacts are out of date. Run 'npm --prefix packages/mcp run gen:openapi' and regenerate the Python models, then commit."
68+
exit 1
69+
fi

packages/mcp/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@qverisai/mcp",
3-
"version": "0.6.0",
4-
"description": "QVeris MCP server for agent tool discovery, inspection, and calling",
3+
"version": "0.6.0",
4+
"description": "QVeris MCP server for agent tool discovery, inspection, and calling",
55
"keywords": [
66
"qveris",
77
"mcp",
@@ -14,12 +14,12 @@
1414
"license": "MIT",
1515
"repository": {
1616
"type": "git",
17-
"url": "https://github.com/QVerisAI/qveris-agent-toolkit",
17+
"url": "https://github.com/QVerisAI/qveris-agent-toolkit",
1818
"directory": "packages/mcp"
1919
},
2020
"homepage": "https://qveris.ai",
2121
"bugs": {
22-
"url": "https://github.com/QVerisAI/qveris-agent-toolkit/issues"
22+
"url": "https://github.com/QVerisAI/qveris-agent-toolkit/issues"
2323
},
2424
"type": "module",
2525
"main": "dist/index.js",
@@ -38,7 +38,8 @@
3838
"test:watch": "vitest",
3939
"test:coverage": "vitest run --coverage",
4040
"prepublishOnly": "npm run build",
41-
"typecheck": "tsc --noEmit"
41+
"typecheck": "tsc --noEmit",
42+
"gen:openapi": "openapi-typescript ../../docs/openapi/qveris-public-api.openapi.json -o src/generated/openapi.d.ts"
4243
},
4344
"dependencies": {
4445
"@modelcontextprotocol/sdk": "^1.0.0",
@@ -47,6 +48,7 @@
4748
"devDependencies": {
4849
"@types/node": "^22.10.1",
4950
"@types/uuid": "^10.0.0",
51+
"openapi-typescript": "7.4.4",
5052
"typescript": "^5.7.2",
5153
"vitest": "^2.1.0"
5254
},

0 commit comments

Comments
 (0)