(param, paramType, props)
| 171 | } |
| 172 | |
| 173 | async function getTransformedParam(param, paramType, props) { |
| 174 | const { paramKey, required, childParamsGroups, topLevel } = props |
| 175 | const paramDecorated = {} |
| 176 | // Supports backwards compatibility for OpenAPI 3.0 |
| 177 | // In 3.1 a nullable type is part of the param.type array and |
| 178 | // the property param.nullable does not exist. |
| 179 | if (param.nullable) paramType.push('null') |
| 180 | paramDecorated.type = paramType.filter(Boolean).join(' or ') |
| 181 | paramDecorated.name = paramKey |
| 182 | if (topLevel) { |
| 183 | paramDecorated.in = 'body' |
| 184 | } |
| 185 | paramDecorated.description = await renderContent(param.description) |
| 186 | if (required && required.includes(paramKey)) { |
| 187 | paramDecorated.isRequired = true |
| 188 | } |
| 189 | if (childParamsGroups && childParamsGroups.length > 0) { |
| 190 | paramDecorated.childParamsGroups = childParamsGroups |
| 191 | } |
| 192 | if (param.enum) { |
| 193 | paramDecorated.enum = param.enum |
| 194 | } |
| 195 | |
| 196 | // we also want to catch default values of `false` for booleans |
| 197 | if (param.default !== undefined) { |
| 198 | paramDecorated.default = param.default |
| 199 | } |
| 200 | return paramDecorated |
| 201 | } |
no test coverage detected