MCPcopy Index your code
hub / github.com/github/docs / getParameterExamples

Function getParameterExamples

src/rest/scripts/utils/create-rest-examples.js:337–359  ·  view source on GitHub ↗
(operation)

Source from the content-addressed store, hash-verified

335 }
336*/
337export function getParameterExamples(operation) {
338 if (!operation.parameters) {
339 return {}
340 }
341 const parameters = operation.parameters.filter((param) => param.in === 'path')
342 const parameterExamples = {}
343 parameters.forEach((parameter) => {
344 const examples = parameter.examples
345 // If there are no examples, create an example from the uppercase parameter
346 // name, so that it is more visible that the value is fake data
347 // in the route path.
348 if (!examples) {
349 if (!parameterExamples.default) parameterExamples.default = {}
350 parameterExamples.default[parameter.name] = parameter.name.toUpperCase()
351 } else {
352 Object.keys(examples).forEach((key) => {
353 if (!parameterExamples[key]) parameterExamples[key] = {}
354 parameterExamples[key][parameter.name] = examples[key].value
355 })
356 }
357 })
358 return parameterExamples
359}

Callers 1

getRequestExamplesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected