fix(sdk): preserve V2Event name for SSE streams (#34171)

This commit is contained in:
Dax 2026-06-27 21:05:47 -04:00 committed by GitHub
parent ae53163cad
commit 6446b8ae3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 89 additions and 13 deletions

View file

@ -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