(operation)
| 335 | } |
| 336 | */ |
| 337 | export 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 | } |
no outgoing calls
no test coverage detected