Skip to content

Commit

Permalink
Adding support for matrix parameters, part of OAS3
Browse files Browse the repository at this point in the history
  • Loading branch information
ilgrosso authored Jan 7, 2018
1 parent 153cd52 commit bca0491
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/execute/oas3/parameter-builders.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import stylize from './style-serializer'

export default {
path,
matrix,
query,
header,
cookie
Expand All @@ -20,6 +21,22 @@ function path({req, value, parameter}) {
req.url = req.url.replace(`{${name}}`, styledValue)
}

function matrix({req, value, parameter}) {
const {name, style, explode} = parameter
const styledValue = stylize({
key: parameter.name,
value,
style: style || 'simple',
explode: explode || false,
escape: true,
})

var queryStart = req.url.indexOf('?');
var prefix = queryStart == -1 ? req.url : req.url.substr(0, queryStart);
var suffix = queryStart == -1 ? '' : req.url.substr(queryStart);
req.url = prefix + ';' + parameter.name + "=" + styledValue + suffix;
}

function query({req, value, parameter}) {
req.query = req.query || {}

Expand Down

0 comments on commit bca0491

Please sign in to comment.