@asyncapi/parser
Advanced tools
Comparing version 0.27.1 to 0.28.0
@@ -11,2 +11,5 @@ const Ajv = require('ajv'); | ||
/** | ||
* @private | ||
*/ | ||
async function parse({ message, originalAsyncAPIDocument, fileFormat, parsedAsyncAPIDocument, pathToPayload }) { | ||
@@ -31,2 +34,5 @@ const ajv = new Ajv({ | ||
/** | ||
* @private | ||
*/ | ||
function getMimeTypes() { | ||
@@ -47,2 +53,3 @@ return [ | ||
* | ||
* @private | ||
* @param {Object} asyncapiSchema AsyncAPI specification JSON Schema | ||
@@ -62,2 +69,3 @@ * @returns {Object} valid JSON Schema document describing format of AsyncAPI-valid schema for message payload | ||
* | ||
* @private | ||
* @param {Array<Object>} errors Ajv errors | ||
@@ -64,0 +72,0 @@ * @param {String} path Path to location of the payload schema in AsyncAPI Document |
@@ -7,3 +7,3 @@ const ParserError = require('./errors/parser-error'); | ||
* Validates if variables provided in the url have corresponding variable object defined | ||
* | ||
* @private | ||
* @param {Object} parsedJSON parsed AsyncAPI document | ||
@@ -50,2 +50,3 @@ * @param {String} asyncapiYAMLorJSON AsyncAPI document in string | ||
* | ||
* @private | ||
* @param {Object} parsedJSON parsed AsyncAPI document | ||
@@ -93,2 +94,3 @@ * @param {String} asyncapiYAMLorJSON AsyncAPI document in string | ||
* | ||
* @private | ||
* @param {Object} parsedJSON parsed AsyncAPI document | ||
@@ -142,6 +144,7 @@ * @param {String} asyncapiYAMLorJSON AsyncAPI document in string | ||
* | ||
* @private | ||
* @param {Object} parsedJSON parsed AsyncAPI document | ||
* @param {String} asyncapiYAMLorJSON AsyncAPI document in string | ||
* @param {String} initialFormat information of the document was oryginally JSON or YAML | ||
* @param {Array[String]} specialSecTypes list of security types that can have data in array | ||
* @param {String[]} specialSecTypes list of security types that can have data in array | ||
* @returns {Boolean} true in case the document is valid, otherwise throws ParserError | ||
@@ -203,3 +206,3 @@ */ | ||
* @param {Object} components components object from the AsyncAPI document | ||
* @returns {Array[String]} there are 2 elements in array, index 0 is the name of the security schema object and index 1 is it's type | ||
* @returns {String[]} there are 2 elements in array, index 0 is the name of the security schema object and index 1 is it's type | ||
*/ | ||
@@ -225,6 +228,6 @@ function findSecuritySchema(securityName, components) { | ||
* @param {String} schemaType security type, like httpApiKey or userPassword | ||
* @param {Array[String]} specialSecTypes list of special types that do not have to be an empty array | ||
* @param {String[]} specialSecTypes list of special types that do not have to be an empty array | ||
* @param {Object} secObj server security object | ||
* @param {String} secName name os server security object | ||
* @returns {Array[String]} there are 2 elements in array, index 0 is the name of the security schema object and index 1 is it's type | ||
* @returns {String[]} there are 2 elements in array, index 0 is the name of the security schema object and index 1 is it's type | ||
*/ | ||
@@ -246,2 +249,2 @@ function isSrvrSecProperArray(schemaType, specialSecTypes, secObj, secName) { | ||
validateServerSecurity | ||
}; | ||
}; |
@@ -16,2 +16,4 @@ const ERROR_URL_PREFIX = 'https://github.com/asyncapi/parser-js/'; | ||
* Represents an error while trying to parse an AsyncAPI document. | ||
* @alias module:@asyncapi/parser#ParserError | ||
* @extends Error | ||
*/ | ||
@@ -18,0 +20,0 @@ class ParserError extends Error { |
@@ -15,3 +15,4 @@ const { createMapOfType, getMapValueOfType, addExtensions } = require('../utils'); | ||
* Implements functions to deal with the AsyncAPI document. | ||
* @class | ||
* @class | ||
* @alias module:@asyncapi/parser#AsyncAPIDocument | ||
* @extends Base | ||
@@ -150,3 +151,3 @@ * @returns {AsyncAPIDocument} | ||
/** | ||
* @returns {Map<Message>} | ||
* @returns {Map<string, Message>} | ||
*/ | ||
@@ -182,3 +183,3 @@ allMessages() { | ||
/** | ||
* @returns {Map<Schema>} | ||
* @returns {Map<string, Schema>} | ||
*/ | ||
@@ -210,2 +211,8 @@ allSchemas() { | ||
/** | ||
* Assign message keys as message name to all the component messages. | ||
* | ||
* @private | ||
* @param {AsyncAPIDocument} doc | ||
*/ | ||
function assignNameToComponentMessages(doc) { | ||
@@ -224,2 +231,3 @@ if (doc.hasComponents()) { | ||
* | ||
* @private | ||
* @param {AsyncAPIDocument} doc | ||
@@ -239,2 +247,3 @@ */ | ||
* | ||
* @private | ||
* @param {AsyncAPIDocument} doc | ||
@@ -253,2 +262,3 @@ */ | ||
* | ||
* @private | ||
* @param {AsyncAPIDocument} doc | ||
@@ -271,3 +281,4 @@ */ | ||
* | ||
* @param {messages} map of messages | ||
* @private | ||
* @param {Message} map of messages | ||
*/ | ||
@@ -284,3 +295,3 @@ function addNameToKey(messages, number) { | ||
* Function that indicates that a circular reference was detected. | ||
* | ||
* @private | ||
* @param {Schema} schema schema that is currently accessed and need to be checked if it is a first time | ||
@@ -296,2 +307,3 @@ * @param {Array} seenObjects list of objects that were already seen during recursion | ||
* | ||
* @private | ||
* @param {Schema} schema schema that should be marked as circular | ||
@@ -302,9 +314,15 @@ */ | ||
} | ||
/** | ||
* Callback that is called foreach schema found | ||
* @private | ||
* @callback FoundSchemaCallback | ||
* @param {Schema} schema found. | ||
*/ | ||
/** | ||
* Recursively go through each schema and execute callback. | ||
* | ||
* @param {Schema} schemaContent schema. | ||
* @param {Function} callback(schema) | ||
* the function that is called foreach schema found. | ||
* schema {Schema}: the found schema. | ||
* @private | ||
* @param {Schema} schema found. | ||
* @param {FoundSchemaCallback} callback | ||
*/ | ||
@@ -321,2 +339,3 @@ function recursiveSchema(schemaContent, callback) { | ||
* | ||
* @private | ||
* @param {Schema} schemaContent schema. | ||
@@ -360,6 +379,5 @@ * @param {Array} seenObj schema elements that crowler went through already. | ||
* | ||
* @private | ||
* @param {AsyncAPIDocument} doc | ||
* @param {Function} callback(schema) | ||
* the function that is called foreach schema found. | ||
* schema {Schema}: the found schema. | ||
* @param {FoundSchemaCallback} callback | ||
*/ | ||
@@ -394,2 +412,3 @@ function schemaDocument(doc, callback) { | ||
* | ||
* @private | ||
* @param {AsyncAPIDocument} doc | ||
@@ -410,2 +429,3 @@ */ | ||
* | ||
* @private | ||
* @param {Schema} schema Object type. | ||
@@ -433,2 +453,3 @@ * @param {Array} seenObj schema elements that crawler went through already. | ||
* | ||
* @private | ||
* @param {Schema} schema Array type. | ||
@@ -435,0 +456,0 @@ * @param {Array} seenObj schema elements that crowler went through already. |
@@ -6,2 +6,3 @@ const ParserError = require('../errors/parser-error'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Base | ||
* @returns {Base} | ||
@@ -8,0 +9,0 @@ */ |
@@ -8,2 +8,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#ChannelParameter | ||
* @extends Base | ||
@@ -10,0 +11,0 @@ * @returns {ChannelParameter} |
@@ -10,2 +10,3 @@ const { createMapOfType, getMapValueOfType, getMapValueByKey, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Channel | ||
* @extends Base | ||
@@ -12,0 +13,0 @@ * @returns {Channel} |
@@ -14,2 +14,3 @@ const { createMapOfType, getMapValueOfType, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Components | ||
* @extends Base | ||
@@ -16,0 +17,0 @@ * @returns {Components} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Contact | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {Contact} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#CorrelationId | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {CorrelationId} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#ExternalDocs | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {ExternalDocs} |
@@ -8,3 +8,4 @@ const { addExtensions } = require('../utils'); | ||
* Implements functions to deal with the Info object. | ||
* @class Info | ||
* @class | ||
* @alias module:@asyncapi/parser#Info | ||
* @extends Base | ||
@@ -11,0 +12,0 @@ * @returns {Info} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#License | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {License} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#MessageTrait | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {MessageTrait} |
@@ -11,2 +11,3 @@ const { getMapValueOfType, getMapValueByKey, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#MessageTraitable | ||
* @extends Base | ||
@@ -13,0 +14,0 @@ * @returns {MessageTraitable} |
@@ -7,2 +7,3 @@ const MessageTraitable = require('./message-traitable'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Message | ||
* @extends MessageTraitable | ||
@@ -9,0 +10,0 @@ * @returns {Message} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#OAuthFlow | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {OAuthFlow} |
@@ -6,2 +6,3 @@ const OperationTraitable = require('./operation-traitable'); | ||
* @class | ||
* @alias module:@asyncapi/parser#OperationTrait | ||
* @extends OperationTraitable | ||
@@ -8,0 +9,0 @@ * @returns {OperationTrait} |
@@ -9,2 +9,3 @@ const { getMapValueByKey, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#OperationTraitable | ||
* @extends Base | ||
@@ -11,0 +12,0 @@ * @returns {OperationTraitable} |
@@ -7,2 +7,3 @@ const OperationTraitable = require('./operation-traitable'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Operation | ||
* @extends OperationTraitable | ||
@@ -9,0 +10,0 @@ * @returns {Operation} |
@@ -6,2 +6,3 @@ const Operation = require('./operation'); | ||
* @class | ||
* @alias module:@asyncapi/parser#PublishOperation | ||
* @extends Operation | ||
@@ -8,0 +9,0 @@ * @returns {PublishOperation} |
@@ -8,2 +8,3 @@ const { createMapOfType, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Schema | ||
* @extends Base | ||
@@ -10,0 +11,0 @@ * @returns {Schema} |
@@ -8,2 +8,3 @@ const { createMapOfType, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#SecurityScheme | ||
* @extends Base | ||
@@ -10,0 +11,0 @@ * @returns {SecurityScheme} |
@@ -6,2 +6,3 @@ const Base = require('./base'); | ||
* @class | ||
* @alias module:@asyncapi/parser#ServerSecurityRequirement | ||
* @extends Base | ||
@@ -8,0 +9,0 @@ * @returns {ServerSecurityRequirement} |
@@ -7,2 +7,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#ServerVariable | ||
* @extends Base | ||
@@ -9,0 +10,0 @@ * @returns {ServerVariable} |
@@ -9,2 +9,3 @@ const { createMapOfType, getMapValueOfType, getMapValueByKey, addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Server | ||
* @extends Base | ||
@@ -11,0 +12,0 @@ * @returns {Server} |
@@ -6,2 +6,3 @@ const Operation = require('./operation'); | ||
* @class | ||
* @alias module:@asyncapi/parser#SubscribeOperation | ||
* @extends Operation | ||
@@ -8,0 +9,0 @@ * @returns {SubscribeOperation} |
@@ -8,2 +8,3 @@ const { addExtensions } = require('../utils'); | ||
* @class | ||
* @alias module:@asyncapi/parser#Tag | ||
* @extends Base | ||
@@ -10,0 +11,0 @@ * @returns {Tag} |
@@ -21,3 +21,3 @@ const path = require('path'); | ||
/** | ||
* @module Parser | ||
* @module @asyncapi/parser | ||
*/ | ||
@@ -35,3 +35,2 @@ module.exports = { | ||
* | ||
* @name module:Parser#parse | ||
* @param {String} asyncapiYAMLorJSON An AsyncAPI document in JSON or YAML format. | ||
@@ -122,3 +121,2 @@ * @param {Object} [options] Configuration options. | ||
* | ||
* @name module:Parser#parseFromUrl | ||
* @param {String} url URL where the AsyncAPI document is located. | ||
@@ -214,3 +212,2 @@ * @param {Object} [fetchOptions] Configuration to pass to the {@link https://developer.mozilla.org/en-US/docs/Web/API/Request|fetch} call. | ||
* | ||
* @name module:Parser#registerSchemaParser | ||
* @param {string[]} schemaFormats An array of schema formats the given schema parser is able to recognize and transform. | ||
@@ -217,0 +214,0 @@ * @param {Object} parserModule The schema parser module containing parse() and getMimeTypes() functions. |
@@ -263,2 +263,4 @@ const YAML = require('js-yaml'); | ||
* It parses the string and returns an array with all values that are between curly braces, including braces | ||
* @function parseUrlVariables | ||
* @private | ||
*/ | ||
@@ -273,2 +275,4 @@ utils.parseUrlVariables = str => { | ||
* Returns an array of not existing properties in provided object with names specified in provided array | ||
* @function getMissingProps | ||
* @private | ||
*/ | ||
@@ -288,2 +292,4 @@ utils.getMissingProps = (arr, obj) => { | ||
* | ||
* @function groupValidationErrors | ||
* @private | ||
* @param {String} root name of the root element in the AsyncAPI document, for example channels | ||
@@ -290,0 +296,0 @@ * @param {String} errorMessage the text of the custom error message that will follow the path that points the error |
{ | ||
"name": "@asyncapi/parser", | ||
"version": "0.27.1", | ||
"version": "0.28.0", | ||
"description": "JavaScript AsyncAPI parser.", | ||
"main": "lib/index.js", | ||
"types": "types.d.ts", | ||
"directories": { | ||
@@ -13,2 +14,3 @@ "test": "test" | ||
"docs": "jsdoc2md lib/parser.js -f lib/**/*.js > API.md", | ||
"types": "jsdoc -t node_modules/tsd-jsdoc/dist -r lib -d ./", | ||
"prepublishOnly": "npm run bundle", | ||
@@ -50,2 +52,3 @@ "release": "semantic-release", | ||
"semantic-release": "^17.0.4", | ||
"tsd-jsdoc": "^2.5.0", | ||
"uglify-es": "^3.3.9" | ||
@@ -52,0 +55,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
1091849
90
9362
19