( [yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema], )
| 54 | * @internal |
| 55 | */ |
| 56 | export function toOpenAPIEventIteratorContent( |
| 57 | [yieldsRequired, yieldsSchema]: [boolean, JSONSchema], |
| 58 | [returnsRequired, returnsSchema]: [boolean, JSONSchema], |
| 59 | ): Record<string, OpenAPI.MediaTypeObject> { |
| 60 | return { |
| 61 | 'text/event-stream': { |
| 62 | schema: toOpenAPISchema({ |
| 63 | oneOf: [ |
| 64 | { |
| 65 | type: 'object', |
| 66 | properties: { |
| 67 | event: { const: 'message' }, |
| 68 | data: yieldsSchema, |
| 69 | id: { type: 'string' }, |
| 70 | retry: { type: 'number' }, |
| 71 | }, |
| 72 | required: yieldsRequired ? ['event', 'data'] : ['event'], |
| 73 | }, |
| 74 | { |
| 75 | type: 'object', |
| 76 | properties: { |
| 77 | event: { const: 'done' }, |
| 78 | data: returnsSchema, |
| 79 | id: { type: 'string' }, |
| 80 | retry: { type: 'number' }, |
| 81 | }, |
| 82 | required: returnsRequired ? ['event', 'data'] : ['event'], |
| 83 | }, |
| 84 | { |
| 85 | type: 'object', |
| 86 | properties: { |
| 87 | event: { const: 'error' }, |
| 88 | data: {}, |
| 89 | id: { type: 'string' }, |
| 90 | retry: { type: 'number' }, |
| 91 | }, |
| 92 | required: ['event'], |
| 93 | }, |
| 94 | ], |
| 95 | }), |
| 96 | }, |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @internal |
no test coverage detected