diff --git a/lib/parser.js b/lib/parser.js index f5286eaed..6a158f052 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -27,15 +27,20 @@ module.exports = { AsyncAPIDocument, }; +/** + * The complete list of parse configuration options used to parse the given data. + * @typedef {Object} ParserOptions + * @property {String} path - Path to the AsyncAPI document. It will be used to resolve relative references. Defaults to current working dir. + * @property {Object} parse - Options object to pass to {@link https://apidevtools.org/json-schema-ref-parser/docs/options.html|json-schema-ref-parser}. + * @property {Object} resolve - Options object to pass to {@link https://apidevtools.org/json-schema-ref-parser/docs/options.html|json-schema-ref-parser}. + * @property {Boolean} applyTraits - Whether to resolve and apply traits or not. Defaults to true. + */ + /** * Parses and validate an AsyncAPI document from YAML or JSON. * * @param {(String | Object)} asyncapiYAMLorJSON An AsyncAPI document in JSON or YAML format. - * @param {Object} [options] Configuration options. - * @param {String} [options.path] Path to the AsyncAPI document. It will be used to resolve relative references. Defaults to current working dir. - * @param {Object} [options.parse] Options object to pass to {@link https://apidevtools.org/json-schema-ref-parser/docs/options.html|json-schema-ref-parser}. - * @param {Object} [options.resolve] Options object to pass to {@link https://apidevtools.org/json-schema-ref-parser/docs/options.html|json-schema-ref-parser}. - * @param {Object} [options.applyTraits=true] Whether to resolve and apply traits or not. + * @param {ParserOptions} options Configuration options object {@link ParserOptions} * @returns {Promise} The parsed AsyncAPI document. */ async function parse(asyncapiYAMLorJSON, options = {}) { @@ -118,7 +123,7 @@ async function parse(asyncapiYAMLorJSON, options = {}) { * * @param {String} url URL where the AsyncAPI document is located. * @param {Object} [fetchOptions] Configuration to pass to the {@link https://developer.mozilla.org/en-US/docs/Web/API/Request|fetch} call. - * @param {Object} [options] Configuration to pass to the {@link module:Parser#parse} method. + * @param {ParserOptions} [options] Configuration to pass to the {@link ParserOptions} method. * @returns {Promise} The parsed AsyncAPI document. */ function parseFromUrl(url, fetchOptions, options) { @@ -243,7 +248,7 @@ function applyTraits(js) { * @param {Object} parsedJSON parsed AsyncAPI document * @param {String} asyncapiYAMLorJSON AsyncAPI document in string * @param {String} initialFormat information of the document was originally JSON or YAML - * @param {Object} options Configuration options. + * @param {ParserOptions} options Configuration options. {@link ParserOptions} */ async function customChannelsOperations(parsedJSON, asyncapiYAMLorJSON, initialFormat, options) { const promisesArray = []; @@ -274,7 +279,7 @@ async function customChannelsOperations(parsedJSON, asyncapiYAMLorJSON, initialF * @param {Object} parsedJSON parsed AsyncAPI document * @param {String} asyncapiYAMLorJSON AsyncAPI document in string * @param {String} initialFormat information of the document was originally JSON or YAML - * @param {Object} options Configuration options. + * @param {ParserOptions} options Configuration options. {@link ParserOptions} */ async function customComponentsMsgOperations(parsedJSON, asyncapiYAMLorJSON, initialFormat, options) { if (!parsedJSON.components || !parsedJSON.components.messages) return;