mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-11 08:23:41 +00:00
fix(sdk): preserve V2Event name for SSE streams (#34171)
This commit is contained in:
parent
ae53163cad
commit
6446b8ae3b
7 changed files with 89 additions and 13 deletions
|
|
@ -10,6 +10,8 @@ type OpenApiSchema = {
|
|||
readonly enum?: readonly unknown[]
|
||||
readonly properties?: Record<string, OpenApiSchema>
|
||||
readonly required?: readonly string[]
|
||||
readonly contentSchema?: OpenApiSchema
|
||||
readonly contentMediaType?: string
|
||||
}
|
||||
type OpenApiResponse = {
|
||||
readonly description?: string
|
||||
|
|
@ -99,6 +101,21 @@ describe("PublicApi OpenAPI v2 errors", () => {
|
|||
})
|
||||
})
|
||||
|
||||
test("names the v2 event union without the SSE string wrapper collision", () => {
|
||||
const spec = OpenApi.fromApi(PublicApi) as OpenApiSpec
|
||||
|
||||
expect(spec.components.schemas.V2Event1).toBeUndefined()
|
||||
expect(spec.components.schemas.V2Event?.anyOf?.length).toBeGreaterThan(0)
|
||||
expect(spec.components.schemas.V2EventStream).toMatchObject({
|
||||
type: "string",
|
||||
contentMediaType: "application/json",
|
||||
contentSchema: { $ref: "#/components/schemas/V2Event" },
|
||||
})
|
||||
expect(spec.paths["/api/event"]?.get?.responses?.["200"]?.content?.["text/event-stream"]?.schema).toEqual({
|
||||
$ref: "#/components/schemas/V2Event",
|
||||
})
|
||||
})
|
||||
|
||||
test("preserves /api auth responses", () => {
|
||||
const spec = OpenApi.fromApi(PublicApi) as OpenApiSpec
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue