Skip to content

Commit e2960d9

Browse files
committed
Add support for shema examples from parameters
1 parent 71e66a4 commit e2960d9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

swagger-to-har.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,20 @@ var getQueryStrings = function (swagger, path, method, values) {
147147
param = resolveRef(swagger, param['$ref'])
148148
}
149149
if (typeof param.in !== 'undefined' && param.in.toLowerCase() === 'query') {
150+
if (param.name === 'start_date') {
151+
console.log(1)
152+
}
153+
let value = 'SOME_' + (param.type || param.schema.type).toUpperCase() + '_VALUE'
154+
if (typeof values[param.name] !== 'undefined') {
155+
value = values[param.name] + '' /* adding a empty string to convert to string */
156+
} else if (typeof param.default !== 'undefined') {
157+
value = param.default + ''
158+
} else if (typeof param.schema.example !== 'undefined') {
159+
value = param.schema.example + ''
160+
}
150161
queryStrings.push({
151162
name: param.name,
152-
value: typeof values[param.name] === 'undefined'
153-
? (typeof param.default === 'undefined'
154-
? ('SOME_' + (param.type || param.schema.type).toUpperCase() + '_VALUE')
155-
: param.default + '')
156-
: (values[param.name] + '') /* adding a empty string to convert to string */
163+
value: value
157164
})
158165
}
159166
}

0 commit comments

Comments
 (0)