@@ -39,64 +39,64 @@ class AsyncAPIDocument extends Base {
39
39
}
40
40
41
41
/**
42
- * @returns {string }
42
+ * @returns {string } Version.
43
43
*/
44
44
version ( ) {
45
45
return this . _json . asyncapi ;
46
46
}
47
47
48
48
/**
49
- * @returns {Info }
49
+ * @returns {Info } Info.
50
50
*/
51
51
info ( ) {
52
52
return new Info ( this . _json . info ) ;
53
53
}
54
54
55
55
/**
56
- * @returns {string }
56
+ * @returns {string } Id.
57
57
*/
58
58
id ( ) {
59
59
return this . _json . id ;
60
60
}
61
61
62
62
/**
63
- * @returns {boolean }
63
+ * @returns {boolean } If it has servers.
64
64
*/
65
65
hasServers ( ) {
66
66
return ! ! this . _json . servers ;
67
67
}
68
68
69
69
/**
70
- * @returns {object<string, Server> }
70
+ * @returns {object<string, Server> } Servers.
71
71
*/
72
72
servers ( ) {
73
73
return createMapOfType ( this . _json . servers , Server ) ;
74
74
}
75
75
76
76
/**
77
77
* @param {string } name - Name of the server.
78
- * @returns {Server }
78
+ * @returns {Server } The server for given name.
79
79
*/
80
80
server ( name ) {
81
81
return getMapValueOfType ( this . _json . servers , name , Server ) ;
82
82
}
83
83
84
84
/**
85
- * @returns {boolean }
85
+ * @returns {boolean } If it has channels.
86
86
*/
87
87
hasChannels ( ) {
88
88
return ! ! this . _json . channels ;
89
89
}
90
90
91
91
/**
92
- * @returns {object<string, Channel> }
92
+ * @returns {object<string, Channel> } Channels.
93
93
*/
94
94
channels ( ) {
95
95
return createMapOfType ( this . _json . channels , Channel , this ) ;
96
96
}
97
97
98
98
/**
99
- * @returns {string[] }
99
+ * @returns {string[] } An array with channels names.
100
100
*/
101
101
channelNames ( ) {
102
102
if ( ! this . _json . channels ) return [ ] ;
@@ -105,43 +105,43 @@ class AsyncAPIDocument extends Base {
105
105
106
106
/**
107
107
* @param {string } name - Name of the channel.
108
- * @returns {Channel }
108
+ * @returns {Channel } The channel for given name.
109
109
*/
110
110
channel ( name ) {
111
111
return getMapValueOfType ( this . _json . channels , name , Channel , this ) ;
112
112
}
113
113
114
114
/**
115
- * @returns {string }
115
+ * @returns {string } The content type.
116
116
*/
117
117
defaultContentType ( ) {
118
118
return this . _json . defaultContentType || null ;
119
119
}
120
120
121
121
/**
122
- * @returns {boolean }
122
+ * @returns {boolean } If it has Components.
123
123
*/
124
124
hasComponents ( ) {
125
125
return ! ! this . _json . components ;
126
126
}
127
127
128
128
/**
129
- * @returns {Components }
129
+ * @returns {Components } Components
130
130
*/
131
131
components ( ) {
132
132
if ( ! this . _json . components ) return null ;
133
133
return new Components ( this . _json . components ) ;
134
134
}
135
135
136
136
/**
137
- * @returns {boolean }
137
+ * @returns {boolean } If it has messages.
138
138
*/
139
139
hasMessages ( ) {
140
140
return ! ! this . allMessages ( ) . size ;
141
141
}
142
142
143
143
/**
144
- * @returns {Map<string, Message> }
144
+ * @returns {Map<string, Message> } All messages.
145
145
*/
146
146
allMessages ( ) {
147
147
const messages = new Map ( ) ;
@@ -172,7 +172,7 @@ class AsyncAPIDocument extends Base {
172
172
}
173
173
174
174
/**
175
- * @returns {Map<string, Schema> }
175
+ * @returns {Map<string, Schema> } All schemas.
176
176
*/
177
177
allSchemas ( ) {
178
178
const schemas = new Map ( ) ;
@@ -192,7 +192,7 @@ class AsyncAPIDocument extends Base {
192
192
}
193
193
194
194
/**
195
- * @returns {boolean }
195
+ * @returns {boolean } If it has circular refs.
196
196
*/
197
197
hasCircular ( ) {
198
198
return ! ! this . _json [ String ( xParserCircle ) ] ;
@@ -203,7 +203,7 @@ class AsyncAPIDocument extends Base {
203
203
* Assign message keys as message name to all the component messages.
204
204
*
205
205
* @private
206
- * @param {AsyncAPIDocument } doc
206
+ * @param {AsyncAPIDocument } doc Document.
207
207
*/
208
208
function assignNameToComponentMessages ( doc ) {
209
209
if ( doc . hasComponents ( ) ) {
@@ -219,7 +219,7 @@ function assignNameToComponentMessages(doc) {
219
219
* Assign parameter keys as uid for the parameter schema.
220
220
*
221
221
* @private
222
- * @param {AsyncAPIDocument } doc
222
+ * @param {AsyncAPIDocument } doc Document.
223
223
*/
224
224
function assignUidToParameterSchemas ( doc ) {
225
225
doc . channelNames ( ) . forEach ( channelName => {
@@ -234,7 +234,7 @@ function assignUidToParameterSchemas(doc) {
234
234
* Assign uid to component schemas.
235
235
*
236
236
* @private
237
- * @param {AsyncAPIDocument } doc
237
+ * @param {AsyncAPIDocument } doc Document.
238
238
*/
239
239
function assignUidToComponentSchemas ( doc ) {
240
240
if ( doc . hasComponents ( ) ) {
@@ -248,7 +248,7 @@ function assignUidToComponentSchemas(doc) {
248
248
* Assign anonymous names to nameless messages.
249
249
*
250
250
* @private
251
- * @param {AsyncAPIDocument } doc
251
+ * @param {AsyncAPIDocument } doc Document.
252
252
*/
253
253
function assignNameToAnonymousMessages ( doc ) {
254
254
let anonymousMessageCounter = 0 ;
@@ -264,9 +264,11 @@ function assignNameToAnonymousMessages(doc) {
264
264
265
265
/**
266
266
* Add anonymous name to key if no name provided.
267
- *
267
+ *
268
268
* @private
269
- * @param {Message } map of messages
269
+ * @param messages
270
+ * @param number
271
+ * @param {Message } map of messages
270
272
*/
271
273
function addNameToKey ( messages , number ) {
272
274
messages . forEach ( m => {
@@ -278,18 +280,21 @@ function addNameToKey(messages, number) {
278
280
279
281
/**
280
282
* Function that indicates that a circular reference was detected.
283
+ *
281
284
* @private
282
285
* @param {Schema } schema schema that is currently accessed and need to be checked if it is a first time
283
286
* @param {Array } seenObjects list of objects that were already seen during recursion
287
+ * @returns {boolean } If has circular references or not.
284
288
*/
285
289
function isCircular ( schema , seenObjects ) {
286
290
return seenObjects . includes ( schema . json ( ) ) ;
287
291
}
288
292
289
293
/**
290
294
* Mark schema as being a circular ref
291
- *
295
+ *
292
296
* @private
297
+ * @param prop
293
298
* @param {Schema } schema schema that should be marked as circular
294
299
*/
295
300
function markCircular ( schema , prop ) {
@@ -302,15 +307,17 @@ function markCircular(schema, prop) {
302
307
303
308
/**
304
309
* Callback that is called foreach schema found
310
+ *
305
311
* @private
306
312
* @callback FoundSchemaCallback
307
313
* @param {Schema } schema found.
308
- */
314
+ */
309
315
/**
310
316
* Recursively go through each schema and execute callback.
311
- *
317
+ *
312
318
* @private
313
319
* @param {Schema } schema found.
320
+ * @param schemaContent
314
321
* @param {FoundSchemaCallback } callback
315
322
*/
316
323
function recursiveSchema ( schemaContent , callback ) {
@@ -322,13 +329,15 @@ function recursiveSchema(schemaContent, callback) {
322
329
323
330
/**
324
331
* Schema crawler
325
- *
332
+ *
326
333
* @private
327
334
* @param {Schema } schemaContent schema.
335
+ * @param schema
328
336
* @param {Array } seenObj schema elements that crowler went through already.
329
- * @param {Function } callback(schema)
330
- * the function that is called foreach schema found.
331
- * schema {Schema}: the found schema.
337
+ * @param callback
338
+ * @param {Function } callback(schema)
339
+ * the function that is called foreach schema found.
340
+ * schema {Schema}: the found schema.
332
341
*/
333
342
function crawl ( schema , seenObj , callback ) {
334
343
if ( isCircular ( schema , seenObj ) ) return true ;
@@ -411,13 +420,14 @@ function assignIdToAnonymousSchemas(doc) {
411
420
412
421
/**
413
422
* Recursively go through schema of object type and execute callback.
414
- *
423
+ *
415
424
* @private
416
425
* @param {Schema } schema Object type.
417
426
* @param {Array } seenObj schema elements that crawler went through already.
418
- * @param {Function } callback(schema)
419
- * the function that is called foreach schema found.
420
- * schema {Schema}: the found schema.
427
+ * @param callback
428
+ * @param {Function } callback(schema)
429
+ * the function that is called foreach schema found.
430
+ * schema {Schema}: the found schema.
421
431
*/
422
432
function recursiveSchemaObject ( schema , seenObj , callback ) {
423
433
if ( schema . additionalProperties ( ) !== undefined && typeof schema . additionalProperties ( ) !== 'boolean' ) {
@@ -434,13 +444,14 @@ function recursiveSchemaObject(schema, seenObj, callback) {
434
444
435
445
/**
436
446
* Recursively go through schema of array type and execute callback.
437
- *
447
+ *
438
448
* @private
439
449
* @param {Schema } schema Array type.
440
450
* @param {Array } seenObj schema elements that crowler went through already.
441
- * @param {Function } callback(schema)
442
- * the function that is called foreach schema found.
443
- * schema {Schema}: the found schema.
451
+ * @param callback
452
+ * @param {Function } callback(schema)
453
+ * the function that is called foreach schema found.
454
+ * schema {Schema}: the found schema.
444
455
*/
445
456
function recursiveSchemaArray ( schema , seenObj , callback ) {
446
457
if ( schema . additionalItems ( ) !== undefined ) {
0 commit comments