Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for explode #208

Merged
merged 3 commits into from
Apr 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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