fix(sdk): preserve V2Event name for SSE streams

This commit is contained in:
Dax Raad
2026-06-27 00:53:29 -04:00
parent eb923c27ca
commit 33538fdf44
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