MCPcopy Create free account
hub / github.com/middleapi/orpc / toOpenAPIEventIteratorContent

Function toOpenAPIEventIteratorContent

packages/openapi/src/openapi-utils.ts:56–98  ·  view source on GitHub ↗
(
  [yieldsRequired, yieldsSchema]: [boolean, JSONSchema],
  [returnsRequired, returnsSchema]: [boolean, JSONSchema],
)

Source from the content-addressed store, hash-verified

54 * @internal
55 */
56export 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

Callers 3

#requestMethod · 0.90
#successResponseMethod · 0.90

Calls 1

toOpenAPISchemaFunction · 0.85

Tested by

no test coverage detected