(openapi,shape)
| 243 | } |
| 244 | |
| 245 | function transformShape(openapi,shape){ |
| 246 | shape = _.cloneDeep(shape); |
| 247 | |
| 248 | if (shape.type == 'structure') shape.type = 'object'; |
| 249 | if (shape.type == 'float') { |
| 250 | shape.type = 'number'; |
| 251 | shape.format = 'float'; |
| 252 | } |
| 253 | if (shape.type == 'long') { |
| 254 | shape.type = 'integer'; // TODO verify this, is it simply an unbounded integer? |
| 255 | } |
| 256 | rename(shape,'members','properties'); |
| 257 | if (shape.documentation) { |
| 258 | shape.description = clean(shape.documentation); |
| 259 | delete shape.documentation; |
| 260 | } |
| 261 | |
| 262 | if (shape.type == 'blob') { |
| 263 | shape.type = 'string'; |
| 264 | } |
| 265 | |
| 266 | if (shape.type == 'string') { |
| 267 | if (typeof shape.min !== 'undefined') { |
| 268 | rename(shape,'min','minLength'); |
| 269 | } |
| 270 | if (typeof shape.max !== 'undefined') { |
| 271 | rename(shape,'max','maxLength'); |
| 272 | } |
| 273 | if (typeof shape.minLength === 'string') { |
| 274 | shape.minLength = parseInt(shape.minLength,10); |
| 275 | } |
| 276 | if (typeof shape.maxLength === 'string') { |
| 277 | shape.maxLength = parseInt(shape.maxLength,10); |
| 278 | } |
| 279 | if (shape.sensitive) { |
| 280 | shape.format = 'password'; |
| 281 | delete shape.sensitive; |
| 282 | } |
| 283 | if (shape.pattern) { |
| 284 | try { |
| 285 | var regex = new RegExp(shape.pattern); |
| 286 | } |
| 287 | catch (e) { |
| 288 | shape.pattern = convertRegex(shape.pattern); |
| 289 | try { |
| 290 | var regex = new RegExp(shape.pattern); |
| 291 | } |
| 292 | catch (ex) { |
| 293 | rename(shape,'pattern','x-pattern'); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | if (shape.type == 'integer') { |
| 300 | rename(shape,'min','minimum'); |
| 301 | rename(shape,'max','maximum'); |
| 302 | if (typeof shape.minimum === 'string') { |
no test coverage detected