MCPcopy Index your code
hub / github.com/massCodeIO/massCode / parseParameters

Function parseParameters

src/main/http/import/openapi.ts:188–231  ·  view source on GitHub ↗
(
  rawParameters: unknown[],
  root: UnknownRecord,
)

Source from the content-addressed store, hash-verified

186}
187
188function parseParameters(
189 rawParameters: unknown[],
190 root: UnknownRecord,
191): {
192 headers: HttpHeaderEntry[]
193 pathExamples: Record<string, string>
194 query: HttpQueryEntry[]
195 } {
196 const headers: HttpHeaderEntry[] = []
197 const pathExamples: Record<string, string> = {}
198 const query: HttpQueryEntry[] = []
199
200 for (const rawParameter of rawParameters) {
201 const parameter = resolveRef(root, rawParameter)
202 if (!isRecord(parameter))
203 continue
204
205 const name = asString(parameter.name)
206 if (!name)
207 continue
208
209 const entry = {
210 description: asString(parameter.description) || undefined,
211 key: name,
212 value: getParameterValue(parameter),
213 }
214
215 if (parameter.in === 'query') {
216 query.push(entry)
217 continue
218 }
219
220 if (parameter.in === 'header') {
221 headers.push(entry)
222 continue
223 }
224
225 if (parameter.in === 'path') {
226 pathExamples[name] = entry.value
227 }
228 }
229
230 return { headers, pathExamples, query }
231}
232
233function mergeQueryEntries(
234 urlQuery: HttpQueryEntry[],

Callers 1

parseOperationFunction · 0.85

Calls 4

resolveRefFunction · 0.85
getParameterValueFunction · 0.85
isRecordFunction · 0.70
asStringFunction · 0.70

Tested by

no test coverage detected