@readme/openapi-parser
Advanced tools
+23
-1
@@ -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 @@ * |
+23
-1
@@ -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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
249311
1.57%2119
2.12%