api-schema-builder
Advanced tools
Comparing version 1.0.8 to 1.0.9
{ | ||
"name": "api-schema-builder", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "build schema with validators for each endpoint", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -60,2 +60,3 @@ 'use strict'; | ||
let requestSchema = {}; | ||
let localParameters = []; | ||
let pathParameters = dereferenced.paths[currentPath].parameters || []; | ||
@@ -66,2 +67,3 @@ const isOpenApi3 = dereferenced.openapi === '3.0.0'; | ||
requestSchema.body = oai3.buildRequestBodyValidation(dereferenced, referenced, currentPath, currentMethod, options); | ||
localParameters = oai3.buildPathParameters(parameters, pathParameters); | ||
} else { | ||
@@ -82,8 +84,6 @@ 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,5 +12,13 @@ | ||
buildRequestBodyValidation, | ||
buildHeadersValidation | ||
buildHeadersValidation, | ||
buildPathParameters | ||
}; | ||
function buildPathParameters(parameters, pathParameters) { | ||
let localParameters = parameters.filter(function (parameter) { | ||
return parameter.in !== 'body'; | ||
}).concat(pathParameters); | ||
return localParameters; | ||
} | ||
function getValidatedBodySchema(bodySchema) { | ||
@@ -17,0 +25,0 @@ let validatedBodySchema; |
@@ -14,3 +14,4 @@ const Validators = require('../validators/index'), | ||
buildResponseBodyValidation, | ||
buildHeadersValidation | ||
buildHeadersValidation, | ||
buildPathParameters | ||
}; | ||
@@ -61,2 +62,18 @@ | ||
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.assign(clonedData, schema); | ||
} | ||
return clonedData; | ||
} | ||
function buildHeadersValidation(responses, statusCode, { ajvConfigParams, formats, keywords, contentTypeValidation }) { | ||
@@ -63,0 +80,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
53020
768