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 1.0.0 to 1.0.1-beta

4

index.js

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

// TODO: in future (when OAS is fixed), retrieve headers from components object
// const { securitySchemes } = components;
const { securitySchemes } = components;
const overview = createOverview(info);
const operations = createOperations(baseURL, paths);
const operations = createOperations(baseURL, paths, securitySchemes);

@@ -24,0 +24,0 @@ // TODO: below is used to list env variables in .env.template (stil needs to be implemented)

{
"name": "@trusource/simple-oas",
"version": "1.0.0",
"version": "1.0.1-beta",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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

const createOperation = (url, path, method, operation) => {
const createOperation = (url, securitySchemes, path, method, operation) => {
// TODO: get description too?

@@ -21,3 +21,3 @@ const { operationId, parameters = [], security = [], servers = [] } = operation;

const securitySchemes = createSecuritySchemes(security);
const schemes = createSecuritySchemes(security, securitySchemes);

@@ -36,3 +36,3 @@ return {

headers,
securitySchemes,
securitySchemes: schemes,
};

@@ -39,0 +39,0 @@ }

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

// operations for path
const createPathOperations = (url, path, pathItem) => {
const createPathOperations = (url, securitySchemes, path, pathItem) => {
const supportedOperations = getSupportedOperations(pathItem);
const operations = supportedOperations.map(([method, operation]) => createOperation(url, path, method, operation));
const operations = supportedOperations.map(([method, operation]) => createOperation(url, securitySchemes, path, method, operation));
return operations.sort(sortByMethod);

@@ -22,4 +22,4 @@ }

// If using Node.js v11+ flatMap is supported
const createOperations = (baseURL, paths) => flatMap(Object.entries(paths), ([path, pathItem]) => createPathOperations(baseURL, path, pathItem));
const createOperations = (baseURL, paths, securitySchemes) => flatMap(Object.entries(paths), ([path, pathItem]) => createPathOperations(baseURL, securitySchemes, path, pathItem));
module.exports = createOperations;

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

// we currently will always have one object
const createSecuritySchemes = (security) => {
const createSecuritySchemes = (security, securitySchemes) => {
if (security.length > 1) throw new Error('TruSource currently does not support multiple authentication types using logical OR.');
const securitySchemes = security.length === 1 ? Object.keys(security[0]).map(name => {
const schemes = security.length === 1 ? Object.keys(security[0]).map(name => {
if (!securitySchemes.hasOwnProperty(name)) throw new Error('Error finding security scheme');
return securitySchemes[name];
}) : [];
return securitySchemes;
return schemes;
}
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