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

api-schema-builder

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-schema-builder - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

2

package.json
{
"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`);

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