New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@asyncapi/parser

Package Overview
Dependencies
Maintainers
3
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@asyncapi/parser - npm Package Compare versions

Comparing version 0.18.1 to 0.18.2

.github/workflows/pull-request-testing.yml

31

lib/models/asyncapi.js

@@ -271,15 +271,28 @@ const { createMapOfType, getMapKeyOfType, addExtensions } = require('../utils');

case 'object':
const props = schema.properties();
for (const [, propertySchema] of Object.entries(props)) {
recursiveSchema(propertySchema, callback);
if(schema.additionalProperties() !== undefined && typeof schema.additionalProperties() !== "boolean"){
const additionalSchema = schema.additionalProperties()
recursiveSchema(additionalSchema, callback);
}
if(schema.properties() !== null){
const props = schema.properties();
for (const [, propertySchema] of Object.entries(props)) {
recursiveSchema(propertySchema, callback);
}
}
break;
case 'array':
if (Array.isArray(schema.items())) {
schema.items().forEach(arraySchema => {
recursiveSchema(arraySchema, callback);
});
} else {
recursiveSchema(schema.items(), callback);
if(schema.additionalItems() !== undefined){
const additionalArrayItems = schema.additionalItems()
recursiveSchema(additionalArrayItems, callback);
}
if(schema.items() !== null){
if (Array.isArray(schema.items())) {
schema.items().forEach(arraySchema => {
recursiveSchema(arraySchema, callback);
});
} else {
recursiveSchema(schema.items(), callback);
}
}
break;

@@ -286,0 +299,0 @@ }

@@ -131,3 +131,3 @@ const { addExtensions } = require('../utils');

/**
* @returns {string}
* @returns {string|string[]}
*/

@@ -134,0 +134,0 @@ type() {

{
"name": "@asyncapi/parser",
"version": "0.18.1",
"version": "0.18.2",
"description": "JavaScript AsyncAPI parser.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -190,2 +190,75 @@ const { expect } = require('chai');

describe('#allSchemas()', function () {
it('should return additional items schemas when no items specified', () => {
const doc = {
"channels": {
"some_channel": {
"subscribe": {
"message": {
"name": "some_map",
"payload": {
"type": "array",
"$id": "payloadSchema",
"test": true,
"additionalItems": {
"type": "string",
"$id": "additionalItemSchema",
"test": true
}
}
}
}
}
}
};
const d = new AsyncAPIDocument(doc);
const schemas = d.allSchemas();
expect(schemas.size).to.be.equal(2);
//Ensure the actual keys are as expected
const schemaKeys = Array.from(schemas.keys());
expect(schemaKeys).to.deep.equal([
"payloadSchema",
"additionalItemSchema"
])
for (const t of schemas.values()) {
expect(t.constructor.name).to.be.equal('Schema');
expect(t.json().test).to.be.equal(true);
}
});
it('should return additional property schemas when no properties are specified', () => {
const doc = {
"channels": {
"some_channel": {
"subscribe": {
"message": {
"name": "some_map",
"payload": {
"type": "object",
"$id": "payloadSchema",
"test": true,
"additionalProperties": {
"type": "string",
"$id": "additionalPropSchema",
"test": true
}
}
}
}
}
}
};
const d = new AsyncAPIDocument(doc);
const schemas = d.allSchemas();
expect(schemas.size).to.be.equal(2);
//Ensure the actual keys are as expected
const schemaKeys = Array.from(schemas.keys());
expect(schemaKeys).to.deep.equal([
"payloadSchema",
"additionalPropSchema"
])
for (const t of schemas.values()) {
expect(t.constructor.name).to.be.equal('Schema');
expect(t.json().test).to.be.equal(true);
}
});
it('should return a map with all the schemas used in the document', () => {

@@ -218,3 +291,2 @@ const doc = { channels: { test: { parameters: { testParam1: { schema: { $id: 'testParamSchema', test: true, k: 0 } } }, publish: { message: { headers: { test: true, k: 1 }, payload: { test: true, k: 2 } } } }, test2: { subscribe: { message: { payload: { $id: 'testPayload', test: true, k: 2 } } } } }, components: { schemas: { testSchema: { test: true, k: 3 } } } };

const schemaKeys = Array.from(schemas.keys());
console.log(schemaKeys);
expect(schemaKeys).to.deep.equal([

@@ -221,0 +293,0 @@ "testParamSchema",

@@ -183,3 +183,3 @@ const { expect } = require('chai');

it('should return an array', () => {
it('should return an array of strings', () => {
const doc = { "type": ["number", "string"] };

@@ -186,0 +186,0 @@ const d = new Schema(doc);

@@ -209,3 +209,3 @@ const { EOL } = require('os');

try {
await parser.parse(inputYAML)
await parser.parse(inputYAML, { path: __filename })
} catch (e) {

@@ -226,3 +226,3 @@ expect(e.refs).to.deep.equal([{

try {
await parser.parse(inputJSON)
await parser.parse(inputJSON, { path: __filename })
} catch (e) {

@@ -243,3 +243,3 @@ expect(e.refs).to.deep.equal([{

try {
await parser.parse(JSON.parse(inputJSON))
await parser.parse(JSON.parse(inputJSON), { path: __filename })
} catch (e) {

@@ -322,3 +322,3 @@ expect(e.refs).to.deep.equal([{

expect(e.detail).to.equal(`bad indentation of a mapping entry at line 19, column 11:\n $ref: "#/components/schemas/sentAt"\n ^`);
expect(e.location).to.deep.equal({ startOffset: 460, startLine: 19, startColumn: 11 });
expect(e.location).to.deep.equal({ startOffset: offset(460, 19), startLine: 19, startColumn: 11 });
}

@@ -325,0 +325,0 @@ });

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

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

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