Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@trusource/simple-oas

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@trusource/simple-oas - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

index.js

@@ -13,3 +13,5 @@ 'use strict';

const { info, servers, paths, components } = oas;
const {
info, servers, paths, components,
} = oas;

@@ -40,2 +42,2 @@ const { url: baseURL } = servers[0];

module.exports = createSimpleSpec;
module.exports = createSimpleSpec;
{
"name": "@trusource/simple-oas",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -11,3 +11,3 @@ "main": "index.js",

"license": "ISC",
"gitHead": "75849549ee2014bf6085048cfa7a9480db6dabf4"
"gitHead": "a946de6bd8446c9692ed6ab51c1e90ad7e16f342"
}
'use strict';
// Methods we currently support
// Note: order matters so we can make sure 2 OAS specifications with methods in different orders lead to the same output
// Note: order matters so 2 specifications with methods in different orders lead to the same output
const METHODS = { get: 0 };
// const methods = { get: 0, put: 1, post: 2, delete: 3 }
module.exports = { METHODS };
module.exports = { METHODS };

@@ -5,2 +5,2 @@ 'use strict';

module.exports = flatMap;
module.exports = flatMap;

@@ -6,7 +6,7 @@ 'use strict';

// Sorting
const alphabeticalSort = key => (first, second) => {
const alphabeticalSort = (key) => (first, second) => {
if (first[key] < second[key]) { return -1; }
if (first[key] > second[key]) { return 1; }
return 0;
}
};

@@ -20,2 +20,2 @@ const sortByName = alphabeticalSort('name');

module.exports = { sortByName, sortByPath, sortByMethod };
module.exports = { sortByName, sortByPath, sortByMethod };

@@ -8,3 +8,5 @@ 'use strict';

// TODO: get description too?
const { operationId, parameters = [], security = [], servers = [] } = operation;
const {
operationId, parameters = [], security = [], servers = [],
} = operation;

@@ -32,9 +34,9 @@ // Use global baseURL if no servers url at operation level

pathParams: pathParameters,
queryParamsRequired: queryParameters.filter(qp => qp.required),
queryParamsOptional: queryParameters.filter(qp => !qp.required),
queryParamsRequired: queryParameters.filter((qp) => qp.required),
queryParamsOptional: queryParameters.filter((qp) => !qp.required),
headers,
securitySchemes: schemes,
};
}
};
module.exports = createOperation;

@@ -8,3 +8,3 @@ 'use strict';

const isSupportedOperation = operation => METHODS.hasOwnProperty(operation.toLowerCase());
const isSupportedOperation = (operation) => Object.prototype.hasOwnProperty.call(METHODS, operation.toLowerCase());

@@ -18,3 +18,3 @@ const getSupportedOperations = (pathItem) => Object.entries(pathItem).filter(([key]) => isSupportedOperation(key));

return operations.sort(sortByMethod);
}
};

@@ -25,2 +25,2 @@ // operations for all paths

module.exports = createOperations;
module.exports = createOperations;
'use strict';
// TODO: rename to info (and update templates)
// TODO: do we need create overview?
// TODO: do we need create overview?
// use data from spec directly?
const createOverview = ({ title: name, description, contact, 'x-category': category }) => ({
const createOverview = ({
title: name, description, contact, 'x-category': category,
}) => ({
name,

@@ -9,0 +11,0 @@ description,

@@ -9,10 +9,10 @@ 'use strict';

// very important pathParameters are sorted
const getPathParameters = parameters => parameters
.filter(param => param.in === 'path')
// .map(({ name, schema, required, example, }) => ({ name, required, type: schema.type, example, }));
const getPathParameters = (parameters) => parameters
.filter((param) => param.in === 'path')
// .map(({ schema, ...rest }) => ({ ...rest, type: schema.type }));
.sort(sortByName);
const getQueryParameters = parameters => parameters
.filter(param => param.in === 'query')
// .map(({ name, schema, required, example, }) => ({ name, required, type: schema.type, example, }));
const getQueryParameters = (parameters) => parameters
.filter((param) => param.in === 'query')
// .map(({ schema, ...rest }) => ({ ...rest, type: schema.type }));
.sort(sortByName);

@@ -23,3 +23,3 @@

// TODO: when OAS is fixed & headers no longer in parameters array - move logic in separate file
const getHeaders = parameters => parameters.filter(param => param.in === 'header');
const getHeaders = (parameters) => parameters.filter((param) => param.in === 'header');

@@ -30,2 +30,2 @@ module.exports = {

getHeaders,
}
};
'use strict';
// get security schemes for this operation
// currently we only support multiple operations with AND so security is of format [ { "security1": [], "security2": [] } ]
// currently we only support multiple operations with AND
// so security is of format [ { "security1": [], "security2": [] } ]
// not format [ { "security1": [] }, { "security2": [] } ] (TODO: check this is OR format)?

@@ -9,9 +10,9 @@ // we currently will always have one object

if (security.length > 1) throw new Error('TruSource currently does not support multiple authentication types using logical OR.');
const schemes = security.length === 1 ? Object.keys(security[0]).map(name => {
if (!securitySchemes.hasOwnProperty(name)) throw new Error('Error finding security scheme');
const schemes = security.length === 1 ? Object.keys(security[0]).map((name) => {
if (!Object.prototype.hasOwnProperty.call(securitySchemes, name)) throw new Error('Error finding security scheme');
return securitySchemes[name];
}) : [];
return schemes;
}
};
module.exports = createSecuritySchemes;
module.exports = createSecuritySchemes;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc