Skip to content

Commit a8d04dd

Browse files
author
Brad Larson
committed
Fix bug with additionalProperties
1 parent 360e2cf commit a8d04dd

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

docs/lib/JSONSchemaMarkdown.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class JSONSchemaMarkdown {
77
constructor() {
88
/**
9-
* Object containing the schema
9+
* Object containing the schema
1010
* @type {Object}
1111
*/
1212
this.schema = null;
@@ -113,7 +113,7 @@ class JSONSchemaMarkdown {
113113
// set this as base path to children.
114114
path = "#" + data["$id"];
115115
}
116-
//
116+
//
117117
this.typeGeneric(name, data, level, path);
118118

119119
if (typeof data.type === "string") {
@@ -133,7 +133,7 @@ class JSONSchemaMarkdown {
133133
}
134134
}
135135
}
136-
136+
137137
/**
138138
* This is the shared template for all other types.
139139
* You may want to override this method to change the order of information in your documentation.
@@ -157,7 +157,7 @@ class JSONSchemaMarkdown {
157157
}
158158

159159
/**
160-
*
160+
*
161161
* @param {name} name The JSON property name
162162
* @param {Object} data The JS data for the schema
163163
* @param {integer} level Indentation level
@@ -186,29 +186,29 @@ class JSONSchemaMarkdown {
186186
}
187187

188188
/**
189-
*
189+
*
190190
* @param {name} name The JSON property name
191191
* @param {Object} data The JS data for the schema
192192
* @param {integer} level Indentation level
193193
* @param {String} path String describing the path of the property
194194
*/
195195
typeBoolean(name, data, level, path) {
196-
196+
197197
}
198198

199199
/**
200-
*
200+
*
201201
* @param {name} name The JSON property name
202202
* @param {Object} data The JS data for the schema
203203
* @param {integer} level Indentation level
204204
* @param {String} path String describing the path of the property
205205
*/
206206
typeNull(name, data, level, path) {
207-
207+
208208
}
209209

210210
/**
211-
*
211+
*
212212
* @param {name} name The JSON property name
213213
* @param {Object} data The JS data for the schema
214214
* @param {integer} level Indentation level
@@ -229,7 +229,7 @@ class JSONSchemaMarkdown {
229229
}
230230

231231
/**
232-
*
232+
*
233233
* @param {name} name The JSON property name
234234
* @param {Object} data The JS data for the schema
235235
* @param {integer} level Indentation level
@@ -247,7 +247,7 @@ class JSONSchemaMarkdown {
247247
}
248248

249249
/**
250-
*
250+
*
251251
* @param {name} name The JSON property name
252252
* @param {Object} data The JS data for the schema
253253
* @param {integer} level Indentation level
@@ -313,11 +313,11 @@ class JSONSchemaMarkdown {
313313
* @see https://json-schema.org/understanding-json-schema/reference/object.html#property-names
314314
* @param {boolean} bool
315315
* @param {Integer} level Indentation level
316-
*
316+
*
317317
*/
318318
writeAdditionalProperties(bool, level) {
319319
if (this.notEmpty(bool)) {
320-
if (bool) {
320+
if (!bool) {
321321
this.writeLine("This schema <u>does not</u> accept additional properties.", level);
322322
} else {
323323
this.writeLine("This schema accepts additional properties.", level);
@@ -330,7 +330,7 @@ class JSONSchemaMarkdown {
330330
* @see https://json-schema.org/understanding-json-schema/reference/generic.html#comments
331331
* @param {String} comment The comment
332332
* @param {Integer} level Indentation level
333-
*
333+
*
334334
*/
335335
writeComment(comment, level) {
336336
if (this.notEmpty(comment)) {
@@ -343,7 +343,7 @@ class JSONSchemaMarkdown {
343343
* @see https://json-schema.org/understanding-json-schema/reference/generic.html
344344
* @param {*} value The default value
345345
* @param {Integer} level Indentation level
346-
*
346+
*
347347
*/
348348
writeDefault(value, level) {
349349
if (this.notEmpty(value)) {
@@ -356,7 +356,7 @@ class JSONSchemaMarkdown {
356356
* @see https://json-schema.org/understanding-json-schema/reference/generic.html
357357
* @param {String} description The description may include markdown
358358
* @param {Integer} level Indentation level
359-
*
359+
*
360360
*/
361361
writeDescription(description, level) {
362362
if (this.notEmpty(description)) {
@@ -368,7 +368,7 @@ class JSONSchemaMarkdown {
368368
* Write *.enum as a list.
369369
* @param {array} list Enumerated values
370370
* @param {Integer} level Indentation level
371-
*
371+
*
372372
*/
373373
writeEnum(list, level) {
374374
if (this.notEmpty(list)) {
@@ -381,7 +381,7 @@ class JSONSchemaMarkdown {
381381
* @see https://json-schema.org/understanding-json-schema/reference/string.html#format
382382
* @param {String} format Format of string
383383
* @param {Integer} level Indentation level
384-
*
384+
*
385385
*/
386386
writeFormat(format, level) {
387387
if (this.notEmpty(format)) {
@@ -394,7 +394,7 @@ class JSONSchemaMarkdown {
394394
* @see https://json-schema.org/understanding-json-schema/reference/generic.html
395395
* @param {array} list Examples
396396
* @param {Integer} level Indentation level
397-
*
397+
*
398398
*/
399399
writeExamples(list, level) {
400400
if (this.notEmpty(list)) {
@@ -406,7 +406,7 @@ class JSONSchemaMarkdown {
406406
/**
407407
* @param {String} header The header to be written
408408
* @param {Integer} level Header level [H1, H2, H3, H4, H5]
409-
*
409+
*
410410
*/
411411
writeHeader(header, level = 1) {
412412
if (this.notEmpty(header)) {
@@ -419,7 +419,7 @@ class JSONSchemaMarkdown {
419419
* @see https://json-schema.org/understanding-json-schema/structuring.html#the-id-property
420420
* @param {String} id the schema's $id
421421
* @param {Integer} level Indentation level
422-
*
422+
*
423423
*/
424424
writeId(id, level) {
425425
if (this.notEmpty(id)) {
@@ -431,7 +431,7 @@ class JSONSchemaMarkdown {
431431
* Write array as markdown list
432432
* @param {array} list Mixed array to list
433433
* @param {Integer} level Indentation level
434-
*
434+
*
435435
*/
436436
writeList(list, level = 1) {
437437
if (this.notEmpty(list)) {
@@ -446,7 +446,7 @@ class JSONSchemaMarkdown {
446446
* Write notation for inclusive minimum and maximum.
447447
* @param {number} min Inclusive minimim
448448
* @param {number} max Inclusive maximum
449-
*
449+
*
450450
*/
451451
writeMinMax(min, max) {
452452
if (this.notEmpty(min) && this.notEmpty(max)) {
@@ -462,7 +462,7 @@ class JSONSchemaMarkdown {
462462
* Write notation for exclusive minimum and maximum.
463463
* @param {number} min Exclusive minimim
464464
* @param {number} max Exclusive maximum
465-
*
465+
*
466466
*/
467467
writeMinMaxExlusive(min, max) {
468468
if (this.notEmpty(min)) {
@@ -480,7 +480,7 @@ class JSONSchemaMarkdown {
480480
* @see https://json-schema.org/understanding-json-schema/reference/numeric.html#multiples
481481
* @param {Number} number Regular Expression that string must match.
482482
* @param {Integer} level Indentation level
483-
*
483+
*
484484
*/
485485
writeMultipleOf(number, level) {
486486
if (this.notEmpty(number)) {
@@ -492,7 +492,7 @@ class JSONSchemaMarkdown {
492492
* @see https://json-schema.org/understanding-json-schema/reference/string.html#regular-expressions
493493
* @param {String} pattern Regular Expression that string must match.
494494
* @param {Integer} level Indentation level
495-
*
495+
*
496496
*/
497497
writePattern(pattern, level) {
498498
if (this.notEmpty(pattern)) {
@@ -505,7 +505,7 @@ class JSONSchemaMarkdown {
505505
* @see https://json-schema.org/understanding-json-schema/reference/object.html#property-names
506506
* @param {String} data Schema object
507507
* @param {Integer} level Indentation level
508-
*
508+
*
509509
*/
510510
writePropertyNames(data, level) {
511511
if (this.notEmpty(data) && this.notEmpty(data.pattern)) {
@@ -518,7 +518,7 @@ class JSONSchemaMarkdown {
518518
* @param {Integer} level Indentation level
519519
* @param {String} path String describing the path of the property
520520
* @param {boolean} required Property is required (True or False [default])
521-
*
521+
*
522522
*/
523523
writePropertyName(prop, level, path, required = false) {
524524
this.indent(level);
@@ -534,7 +534,7 @@ class JSONSchemaMarkdown {
534534
* @see https://json-schema.org/understanding-json-schema/structuring.html#reuse
535535
* @param {String} ref $ID, path, or URI
536536
* @param {Integer} level Indentation level
537-
*
537+
*
538538
*/
539539
writeRef(ref, level) {
540540
if (this.notEmpty(ref)) {
@@ -546,7 +546,7 @@ class JSONSchemaMarkdown {
546546
* Writes the path for reference purposes
547547
* @param {Integer} level Indentation level
548548
* @param {String} path String describing the path of the property
549-
*
549+
*
550550
*/
551551
writePath(level, path) {
552552
if (this.notEmpty(path)) {
@@ -559,7 +559,7 @@ class JSONSchemaMarkdown {
559559
* @see https://json-schema.org/understanding-json-schema/basics.html#declaring-a-json-schema
560560
* @param {String} uri
561561
* @param {Integer} level Indentation level
562-
*
562+
*
563563
*/
564564
writeSchema(uri, level) {
565565
if (this.notEmpty(uri)) {
@@ -571,7 +571,7 @@ class JSONSchemaMarkdown {
571571
* Writes a section name
572572
* @param {String} name
573573
* @param {Integer} level Indentation level
574-
*
574+
*
575575
*/
576576
writeSectionName(name, level = 1) {
577577
if (this.notEmpty(name)) {
@@ -583,7 +583,7 @@ class JSONSchemaMarkdown {
583583
* @see https://json-schema.org/understanding-json-schema/basics.html#the-type-keyword
584584
* @param {String} type
585585
* @param {Integer} level Indentation level
586-
*
586+
*
587587
*/
588588
writeType(type, level) {
589589
if (this.notEmpty(type)) {
@@ -599,7 +599,7 @@ class JSONSchemaMarkdown {
599599
* @see https://json-schema.org/understanding-json-schema/reference/array.html#uniqueness
600600
* @param {boolean} bool
601601
* @param {Integer} level Indentation level
602-
*
602+
*
603603
*/
604604
writeUniqueItems(bool, level) {
605605
if (this.notEmpty(bool)) {
@@ -612,7 +612,7 @@ class JSONSchemaMarkdown {
612612
/**
613613
* Below are utility methods.
614614
**/
615-
615+
616616
/**
617617
* Handles finding correct method for different schema types.
618618
* @param {String} type The schema type/
@@ -641,7 +641,7 @@ class JSONSchemaMarkdown {
641641
* @param {Integer} level Indentation level
642642
* @param {string} indentChar Character to use for indentation. Defaults to this.indentChar
643643
* @param {type} listChar Character to use for list
644-
*
644+
*
645645
*/
646646
indent(level, indentChar = false, listChar = ' - ') {
647647
if (level > 1) {
@@ -656,7 +656,7 @@ class JSONSchemaMarkdown {
656656
* Converts boolean to string "true" or "false"
657657
* @param {type} bool
658658
* @returns {String}
659-
*
659+
*
660660
*/
661661
valueBool(bool) {
662662
if (typeof bool === "string") {
@@ -670,7 +670,7 @@ class JSONSchemaMarkdown {
670670
* Convert mixed values into markdown notation.
671671
* @param {mixed} value
672672
* @returns {String}
673-
*
673+
*
674674
*/
675675
valueFormat(value) {
676676
if (value === "true" || value === "false") {
@@ -689,7 +689,7 @@ class JSONSchemaMarkdown {
689689
* Handles line break logic.
690690
* @param {String} text
691691
* @param {Integer} level Indentation level
692-
*
692+
*
693693
*/
694694
writeLine(text = "", level = 1) {
695695
this.indent(level);
@@ -698,7 +698,7 @@ class JSONSchemaMarkdown {
698698
this.markdown += "\n";
699699
}
700700
}
701-
701+
702702
/**
703703
* Prepare $ref as a link.
704704
* @param {String} ref The schema $ref
@@ -730,7 +730,7 @@ class JSONSchemaMarkdown {
730730
* Check if value is empty
731731
* @param {*} value
732732
* @returns {Boolean}
733-
*
733+
*
734734
*/
735735
empty(value) {
736736
return typeof value === "undefined"
@@ -743,7 +743,7 @@ class JSONSchemaMarkdown {
743743
* Check if value is NOT empty
744744
* @param {*} value
745745
* @returns {Boolean}
746-
*
746+
*
747747
*/
748748
notEmpty(value) {
749749
return !this.empty(value);
@@ -752,7 +752,7 @@ class JSONSchemaMarkdown {
752752
/**
753753
* Append error to errors array
754754
* @param {String} error Error message
755-
*
755+
*
756756
*/
757757
error(error) {
758758
this.errors.push(error);
@@ -765,4 +765,4 @@ class JSONSchemaMarkdown {
765765
*/
766766
if (typeof module !== "undefined") {
767767
module.exports.JSONSchemaMarkdown = JSONSchemaMarkdown;
768-
}
768+
}

0 commit comments

Comments
 (0)