mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 12:54:42 +00:00
test(generate): add sdk drift guardrails
This commit is contained in:
parent
4ed3afea84
commit
3dee1e7acd
3 changed files with 37 additions and 0 deletions
|
|
@ -14,6 +14,7 @@
|
|||
"typecheck": "bun turbo typecheck",
|
||||
"postinstall": "bun run --cwd packages/opencode fix-node-pty",
|
||||
"prepare": "husky",
|
||||
"generate:check": "bun ./script/check-generate.ts",
|
||||
"random": "echo 'Random script'",
|
||||
"hello": "echo 'Hello World!'",
|
||||
"test": "echo 'do not run tests from root' && exit 1"
|
||||
|
|
|
|||
30
packages/opencode/test/server/question-openapi.test.ts
Normal file
30
packages/opencode/test/server/question-openapi.test.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import { describe, expect, test } from "bun:test"
|
||||
import { Server } from "../../src/server/server"
|
||||
|
||||
describe("question openapi", () => {
|
||||
test("keeps the public reply body inline", async () => {
|
||||
const spec = await Server.openapi()
|
||||
const body = spec.paths["/question/{requestID}/reply"]?.post?.requestBody
|
||||
|
||||
expect(body).toBeDefined()
|
||||
if (!body || "$ref" in body) throw new Error("expected inline request body")
|
||||
|
||||
const media = body.content["application/json"]
|
||||
expect(media).toBeDefined()
|
||||
if (!media || "$ref" in media) throw new Error("expected inline json media type")
|
||||
|
||||
expect(media.schema).toMatchObject({
|
||||
type: "object",
|
||||
required: ["answers"],
|
||||
properties: {
|
||||
answers: {
|
||||
description: "User answers in order of questions (each answer is an array of selected labels)",
|
||||
type: "array",
|
||||
items: {
|
||||
$ref: "#/components/schemas/QuestionAnswer",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
6
script/check-generate.ts
Normal file
6
script/check-generate.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bun
|
||||
|
||||
import { $ } from "bun"
|
||||
|
||||
await $`bun ./script/generate.ts`
|
||||
await $`git diff --exit-code -- packages/sdk/openapi.json packages/sdk/js/src/gen packages/sdk/js/src/v2`
|
||||
Loading…
Add table
Add a link
Reference in a new issue