@trusource/simple-oas
Advanced tools
Comparing version 1.0.0 to 1.0.1-beta
@@ -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; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6982
3