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

[Feature] [SwaggerV2] Create Folders from implicit defined tags #1723

Merged
merged 3 commits into from Nov 22, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion packages/insomnia-importers/src/importers/swagger2.js
Expand Up @@ -107,7 +107,23 @@ function parseEndpoints(document) {
.reduce((flat, arr) => flat.concat(arr), []); // flat single array

const tags = document.tags || [];
const folders = tags.map(tag => {

const implicitTags = endpointsSchemas
.map(endpointSchema => endpointSchema.tags)
.reduce((flat, arr) => flat.concat(arr), []) // flat single array
.reduce((distinct, value) => {
if (!distinct.includes(value)) {
distinct.push(value);
}
return distinct;
}, []) // remove duplicates
.filter(tag => !tags.includes(tag))
.map(tag => ({
name: tag,
desciption: '',
}));

const folders = [...tags, ...implicitTags].map(tag => {
return importFolderItem(tag, defaultParent);
});
const folderLookup = {};
Expand Down