Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
30 changes: 30 additions & 0 deletions packages/opencode/test/server/question-openapi.test.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions script/check-generate.ts
Original file line number Diff line number Diff line change
@@ -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