Skip to content

Commit

Permalink
Add support for explode (#208)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Julián Martínez Escobar <kevinccbsg@gmail.com>
  • Loading branch information
sbingner and kevinccbsg committed Apr 7, 2022
1 parent 972b122 commit 0220c4b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions transforms/paths/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const generator = require('../utils/generator');

const REQUIRED = 'required';
const DEPRECATED = 'deprecated';
const EXPLODE = 'explode';
const NOEXPLODE = 'noexplode';
const BODY_PARAM = 'body';
const FORM_TYPE = 'form';

Expand All @@ -32,6 +34,9 @@ const parameterPayload = (options, schema) => ({
type: 'boolean',
defaultValue: false,
}),
explode: setProperty(options, 'explode', {
type: 'boolean'
}),
schema,
});

Expand All @@ -52,6 +57,8 @@ const parseParameter = param => {
}
const isRequired = extraOptions.includes(REQUIRED);
const isDeprecated = extraOptions.includes(DEPRECATED);
const shouldExplode = extraOptions.includes(EXPLODE);
const shouldNotExplode = extraOptions.includes(NOEXPLODE);
const [description, enumValues, jsonOptions] = formatDescription(param.description);
const options = {
name,
Expand All @@ -60,6 +67,12 @@ const parseParameter = param => {
deprecated: isDeprecated,
description,
};
// Used this format because default when undefined is different depending on if it is a query/form or not
if (shouldExplode) {
options.explode = true;
} else if (shouldNotExplode) {
options.explode = false;
}
const schema = getSchema('@param', param.name)(param.type, enumValues, jsonOptions);
return parameterPayload(options, schema);
};
Expand Down

0 comments on commit 0220c4b

Please sign in to comment.