MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildRouteSchema

Function buildRouteSchema

packages/server/src/middleware/schema.ts:112–158  ·  view source on GitHub ↗
(options: RouteSchemaOptions)

Source from the content-addressed store, hash-verified

110}
111
112export function buildRouteSchema(options: RouteSchemaOptions): Record<string, unknown> {
113 const schema: Record<string, unknown> = {};
114
115 if (options.body) {
116 schema['body'] = jsonSchema(options.body);
117 }
118 if (options.querystring) {
119 schema['querystring'] = jsonSchema(options.querystring);
120 }
121 if (options.params) {
122 schema['params'] = jsonSchema(options.params);
123 }
124 if (options.response || options.rawResponse) {
125 const responses: Record<string, unknown> = {};
126 if (options.response) {
127 for (const [code, zodSchema] of Object.entries(options.response)) {
128 responses[String(code)] = envelopeJsonSchema(zodSchema);
129 }
130 }
131 if (options.rawResponse) {
132 for (const [code, rawSchema] of Object.entries(options.rawResponse)) {
133 responses[String(code)] = rawSchema;
134 }
135 }
136 schema['response'] = responses;
137 }
138 if (options.description) {
139 schema['description'] = options.description;
140 }
141 if (options.summary) {
142 schema['summary'] = options.summary;
143 }
144 if (options.tags) {
145 schema['tags'] = options.tags;
146 }
147 if (options.operationId) {
148 schema['operationId'] = options.operationId;
149 }
150 if (options.consumes) {
151 schema['consumes'] = options.consumes;
152 }
153 if (options.produces) {
154 schema['produces'] = options.produces;
155 }
156
157 return schema;
158}

Callers

nothing calls this directly

Calls 2

envelopeJsonSchemaFunction · 0.85
jsonSchemaFunction · 0.70

Tested by

no test coverage detected