chore: sync openapi spec to upstream v1.0.0; fix watcher

Upstream OpenAPI spec moved from v0.1.104 (7c0bb6af) to v1.0.0 (ff8a7389).
Only delta is removal of OCR confidence-score fields/types, which the SDK
never wrapped — no code changes required.

The watcher previously tried to commit hash/spec updates to main, but the
gitea→github mirror reverts them on every sync, leaving issue #1 with
stale hashes across multiple upstream releases. Watcher now skips the
push and instead refreshes the open tracking issue's body on each run,
posting a comment when upstream moves again while the issue is still open.
This commit is contained in:
2026-04-28 12:37:56 +02:00
parent fc61bc42ad
commit c5bb663bc7
4 changed files with 19742 additions and 24 deletions

View File

@@ -7,7 +7,7 @@ on:
workflow_dispatch: # manual trigger for testing
permissions:
contents: write
contents: read
issues: write
jobs:
@@ -39,29 +39,51 @@ jobs:
if [ "$NEW_HASH" != "$OLD_HASH" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
# Generate diff against stored spec for the issue body
# Diff against the in-tree baseline (.openapi-spec.yaml).
# Maintainer commits a fresh baseline when addressing the issue.
if [ -f .openapi-spec.yaml ]; then
diff -u .openapi-spec.yaml new-spec.yaml > /tmp/spec-diff.txt || true
else
echo "No previous spec stored — first run after diff tracking was added." > /tmp/spec-diff.txt
echo "No baseline .openapi-spec.yaml in repo - commit one to enable diffs." > /tmp/spec-diff.txt
fi
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Open issue on change
- name: Open or refresh tracking issue
if: steps.check.outputs.changed == 'true'
uses: actions/github-script@v7
env:
OLD_HASH: ${{ steps.check.outputs.old }}
NEW_HASH: ${{ steps.check.outputs.new }}
with:
script: |
const fs = require('fs');
let diff = fs.readFileSync('/tmp/spec-diff.txt', 'utf8');
// Truncate if too long for issue body
// Truncate if too long for issue body (GitHub issue body limit is 65536 chars)
if (diff.length > 50000) {
diff = diff.substring(0, 50000) + '\n\n... (truncated view full spec for details)';
diff = diff.substring(0, 50000) + '\n\n... (truncated - view full spec for details)';
}
const oldHash = process.env.OLD_HASH;
const newHash = process.env.NEW_HASH;
const body =
`The upstream OpenAPI spec has changed and the SDK is out of sync.\n\n` +
`**Stored hash (.openapi-hash):** \`${oldHash}\`\n` +
`**Current upstream hash:** \`${newHash}\`\n` +
`_Last refreshed: ${new Date().toISOString()}_\n\n` +
`[View upstream spec](https://github.com/mistralai/platform-docs-public/blob/main/openapi.yaml)\n\n` +
`### Diff vs in-tree baseline\n\`\`\`diff\n${diff}\n\`\`\`\n\n` +
`### TODO\n` +
`- [ ] Review spec changes\n` +
`- [ ] Update SDK types if needed\n` +
`- [ ] Run tests\n` +
`- [ ] Bump \`.openapi-hash\` and refresh \`.openapi-spec.yaml\` in same commit\n` +
`- [ ] Close this issue\n\n` +
`<sub>This issue body is rewritten by the watcher each run, so the diff and hashes always reflect the latest upstream state.</sub>`;
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
@@ -73,24 +95,38 @@ jobs:
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '⚠️ Mistral OpenAPI spec has changed',
body: `The upstream OpenAPI spec has been updated.\n\n` +
`**Old hash:** \`${{ steps.check.outputs.old }}\`\n` +
`**New hash:** \`${{ steps.check.outputs.new }}\`\n\n` +
`[View spec](https://github.com/mistralai/platform-docs-public/blob/main/openapi.yaml)\n\n` +
`### Diff\n\`\`\`diff\n${diff}\n\`\`\`\n\n` +
`### TODO\n- [ ] Review spec changes\n- [ ] Update SDK types\n- [ ] Run tests\n- [ ] Update .openapi-hash`,
title: 'Mistral OpenAPI spec has changed',
body,
labels: ['openapi-update']
});
return;
}
- name: Update stored hash and spec
if: steps.check.outputs.changed == 'true'
run: |
echo "${{ steps.check.outputs.new }}" > .openapi-hash
cp new-spec.yaml .openapi-spec.yaml
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .openapi-hash .openapi-spec.yaml
git commit -m "chore: update openapi spec hash"
git push
// Refresh the existing open issue so the diff/hashes never go stale.
const issue = issues.data[0];
// Detect whether upstream moved *again* since the last refresh by
// parsing the previous "Current upstream hash" out of the issue body.
const marker = /\*\*Current upstream hash:\*\* `([a-f0-9]{64})`/;
const prev = (issue.body || '').match(marker);
const movedAgain = prev && prev[1] !== newHash;
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body
});
if (movedAgain) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body:
`Upstream spec moved again since this issue was last refreshed.\n\n` +
`Previous upstream hash: \`${prev[1]}\`\n` +
`New upstream hash: \`${newHash}\`\n\n` +
`Issue body has been updated to the latest diff.`
});
}

View File

@@ -1 +1 @@
7c0bb6afcdae8f7d1fd1402d44e179fa41de3709bb6badeb9c5865559547bd11
ff8a7389b7a4e61145561361537aae37c49f7e2dcf7c4f79f41e80a30b484cc3

19660
.openapi-spec.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,25 @@
## Unreleased
### Changed
- Tracking upstream Mistral OpenAPI spec **v1.0.0** (was v0.1.104).
No SDK surface change: the only spec delta in this window was the
removal of OCR confidence-score fields
(`OCRPageObject.confidence_scores`, `OCRRequest.confidence_scores_granularity`,
`OCRTableObject.word_confidence_scores`, plus the `OCRConfidenceScore`
and `OCRPageConfidenceScores` schemas), none of which were exposed by
this SDK.
### Fixed (CI)
- `watch-openapi.yml` no longer attempts to commit `.openapi-hash` /
`.openapi-spec.yaml` to `main`. The push was being silently reverted
by an upstream mirror, leaving the tracking issue stale across
multiple upstream releases. The watcher now refreshes the open
tracking issue's body on each run so the diff and hashes always
reflect the current upstream state, and posts a comment when the
spec moves again while the issue is still open.
## v1.3.0 — 2026-04-03
Upstream sync with Python SDK v2.3.0. Updates workflow registration model