api-schema-builder
Advanced tools
Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "api-schema-builder", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "build schema with validators for each endpoint", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -60,3 +60,2 @@ 'use strict'; | ||
let requestSchema = {}; | ||
let localParameters = []; | ||
let pathParameters = dereferenced.paths[currentPath].parameters || []; | ||
@@ -67,3 +66,2 @@ const isOpenApi3 = dereferenced.openapi === '3.0.0'; | ||
requestSchema.body = oai3.buildRequestBodyValidation(dereferenced, referenced, currentPath, currentMethod, options); | ||
localParameters = oai3.buildPathParameters(parameters, pathParameters); | ||
} else { | ||
@@ -84,6 +82,8 @@ let bodySchema = options.expectFormFieldsInBody | ||
} | ||
localParameters = oai2.buildPathParameters(parameters, pathParameters); | ||
} | ||
let localParameters = parameters.filter(function (parameter) { | ||
return parameter.in !== 'body'; | ||
}).concat(pathParameters); | ||
if (localParameters.length > 0 || options.contentTypeValidation) { | ||
@@ -90,0 +90,0 @@ requestSchema.parameters = buildParametersValidation(localParameters, |
@@ -12,13 +12,5 @@ | ||
buildRequestBodyValidation, | ||
buildHeadersValidation, | ||
buildPathParameters | ||
buildHeadersValidation | ||
}; | ||
function buildPathParameters(parameters, pathParameters) { | ||
let localParameters = parameters.filter(function (parameter) { | ||
return parameter.in !== 'body'; | ||
}).concat(pathParameters); | ||
return localParameters; | ||
} | ||
function getValidatedBodySchema(bodySchema) { | ||
@@ -25,0 +17,0 @@ let validatedBodySchema; |
@@ -14,4 +14,3 @@ const Validators = require('../validators/index'), | ||
buildResponseBodyValidation, | ||
buildHeadersValidation, | ||
buildPathParameters | ||
buildHeadersValidation | ||
}; | ||
@@ -62,20 +61,2 @@ | ||
function buildPathParameters(parameters, pathParameters) { | ||
let allParameters = [].concat(parameters, pathParameters); | ||
let localParameters = allParameters.map(handleSchema); | ||
return localParameters; | ||
} | ||
function handleSchema(data) { | ||
let clonedData = cloneDeep(data); | ||
let schema = data.schema; | ||
if (schema) { | ||
delete clonedData['schema']; | ||
Object.keys(schema).forEach(key => { | ||
clonedData[key] = schema[key]; | ||
}); | ||
} | ||
return clonedData; | ||
} | ||
function buildHeadersValidation(responses, statusCode, { ajvConfigParams, formats, keywords, contentTypeValidation }) { | ||
@@ -82,0 +63,0 @@ let headers = get(responses, `[${statusCode}].headers`); |
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
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
52203
745