🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

@readme/openapi-parser

Package Overview
Dependencies
Maintainers
8
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@readme/openapi-parser - npm Package Compare versions

Comparing version
5.3.1
to
5.4.0
+23
-1
dist/index.cjs

@@ -394,3 +394,5 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;

}
const parameterId = `${operationId}/parameters/${param.name}`;
if (!param.schema && param.content) {
this.validateParameterContent(param.content, parameterId);
return;

@@ -400,3 +402,2 @@ } else if ("$ref" in param.schema) {

}
const parameterId = `${operationId}/parameters/${param.name}`;
this.validateSchema(param.schema, parameterId);

@@ -406,2 +407,23 @@ });

/**
* Validates parameter content object.
* Note: The requirement for exactly one media type is already enforced by the OpenAPI JSON schema.
*/
validateParameterContent(content, parameterId) {
const mediaTypes = Object.keys(content);
if (mediaTypes.length !== 1) {
this.reportError(
`\`${parameterId}\` must have exactly one media type in \`content\`, but found ${mediaTypes.length}.`
);
return;
}
const mediaType = mediaTypes[0];
const contentSchema = content[mediaType].schema;
if (contentSchema) {
if ("$ref" in contentSchema) {
return;
}
this.validateSchema(contentSchema, `${parameterId}/content/${mediaType}/schema`);
}
}
/**
* Validates the given response object.

@@ -408,0 +430,0 @@ *

@@ -394,3 +394,5 @@ import {

}
const parameterId = `${operationId}/parameters/${param.name}`;
if (!param.schema && param.content) {
this.validateParameterContent(param.content, parameterId);
return;

@@ -400,3 +402,2 @@ } else if ("$ref" in param.schema) {

}
const parameterId = `${operationId}/parameters/${param.name}`;
this.validateSchema(param.schema, parameterId);

@@ -406,2 +407,23 @@ });

/**
* Validates parameter content object.
* Note: The requirement for exactly one media type is already enforced by the OpenAPI JSON schema.
*/
validateParameterContent(content, parameterId) {
const mediaTypes = Object.keys(content);
if (mediaTypes.length !== 1) {
this.reportError(
`\`${parameterId}\` must have exactly one media type in \`content\`, but found ${mediaTypes.length}.`
);
return;
}
const mediaType = mediaTypes[0];
const contentSchema = content[mediaType].schema;
if (contentSchema) {
if ("$ref" in contentSchema) {
return;
}
this.validateSchema(contentSchema, `${parameterId}/content/${mediaType}/schema`);
}
}
/**
* Validates the given response object.

@@ -408,0 +430,0 @@ *

+2
-2
{
"name": "@readme/openapi-parser",
"version": "5.3.1",
"version": "5.4.0",
"description": "Swagger 2.0 and OpenAPI 3.x parser and validator for Node and browsers",

@@ -83,3 +83,3 @@ "license": "MIT",

"prettier": "@readme/standards/prettier",
"gitHead": "190762cfaab7382797f8ce7f510ab3b45db95ab5"
"gitHead": "866765a738dd4114d6e31a0b5bb6b021d04d778f"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display