001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.dto.swagger;
014
015import static org.apache.juneau.internal.BeanPropertyUtils.*;
016import java.util.*;
017
018import org.apache.juneau.annotation.*;
019import org.apache.juneau.internal.*;
020import org.apache.juneau.utils.*;
021
022/**
023 * The Schema Object allows the definition of input and output data types.
024 *
025 * <p>
026 * These types can be objects, but also primitives and arrays.
027 * This object is based on the JSON Schema Specification Draft 4 and uses a predefined subset of it.
028 * On top of this subset, there are extensions provided by this specification to allow for more complete documentation.
029 *
030 * <p>
031 * Further information about the properties can be found in JSON Schema Core and JSON Schema Validation.
032 * Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here.
033 *
034 * <h5 class='section'>Example:</h5>
035 * <p class='bcode w800'>
036 *    <jc>// Construct using SwaggerBuilder.</jc>
037 *    SchemaInfo x = <jsm>schemaInfo</jsm>()
038 *       .type("string")
039 *       .title("foo")
040 *
041 *    <jc>// Serialize using JsonSerializer.</jc>
042 *    String json = JsonSerializer.<jsf>DEFAULT</jsf>.toString(x);
043 *
044 *    <jc>// Or just use toString() which does the same as above.</jc>
045 *    String json = x.toString();
046 * </p>
047 * <p class='bcode w800'>
048 *    <jc>// Output</jc>
049 *    {
050 *       <js>"type"</js>: <js>"string"</js>,
051 *       <js>"title"</js>: <js>"foo"</js>
052 *    }
053 * </p>
054 *
055 * <h5 class='section'>See Also:</h5>
056 * <ul class='doctree'>
057 *    <li class='link'>{@doc juneau-dto.Swagger}
058 * </ul>
059 */
060@Bean(properties="format,title,description,default,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,maxProperties,minProperties,required,enum,type,items,allOf,properties,additionalProperties,discriminator,readOnly,xml,externalDocs,example,$ref,*")
061public class SchemaInfo extends SwaggerElement {
062
063   private String
064      format,
065      title,
066      description,
067      pattern,
068      type,
069      discriminator,
070      ref;
071   private Number
072      multipleOf,
073      maximum,
074      minimum;
075   private Integer
076      maxLength,
077      minLength,
078      maxItems,
079      minItems,
080      maxProperties,
081      minProperties;
082   private Boolean
083      exclusiveMaximum,
084      exclusiveMinimum,
085      uniqueItems,
086      readOnly;
087   private Object
088      _default,
089      example;
090   private Items items;
091   private Xml xml;
092   private ExternalDocumentation externalDocs;
093   private List<Object>
094      _enum,
095      allOf;
096   private List<String>
097      required;
098   private Map<String,SchemaInfo> properties;
099   private SchemaInfo additionalProperties;
100
101   /**
102    * Default constructor.
103    */
104   public SchemaInfo() {}
105
106   /**
107    * Copy constructor.
108    *
109    * @param copyFrom The object to copy.
110    */
111   public SchemaInfo(SchemaInfo copyFrom) {
112      super(copyFrom);
113
114      this.format = copyFrom.format;
115      this.title = copyFrom.title;
116      this.description = copyFrom.description;
117      this.pattern = copyFrom.pattern;
118      this.type = copyFrom.type;
119      this.discriminator = copyFrom.discriminator;
120      this.ref = copyFrom.ref;
121      this.multipleOf = copyFrom.multipleOf;
122      this.maximum = copyFrom.maximum;
123      this.minimum = copyFrom.minimum;
124      this.maxLength = copyFrom.maxLength;
125      this.minLength = copyFrom.minLength;
126      this.maxItems = copyFrom.maxItems;
127      this.minItems = copyFrom.minItems;
128      this.maxProperties = copyFrom.maxProperties;
129      this.minProperties = copyFrom.minProperties;
130      this.exclusiveMaximum = copyFrom.exclusiveMaximum;
131      this.exclusiveMinimum = copyFrom.exclusiveMinimum;
132      this.uniqueItems = copyFrom.uniqueItems;
133      this.readOnly = copyFrom.readOnly;
134      this._default = copyFrom._default;
135      this.example = copyFrom.example;
136      this.items = copyFrom.items == null ? null : copyFrom.items.copy();
137      this.xml = copyFrom.xml == null ? null : copyFrom.xml.copy();
138      this.externalDocs = copyFrom.externalDocs == null ? null : copyFrom.externalDocs.copy();
139      this._enum = newList(copyFrom._enum);
140      this.allOf = newList(copyFrom.allOf);
141      this.required = newList(copyFrom.required);
142
143      this.properties = copyFrom.properties == null ? null : new LinkedHashMap<String,SchemaInfo>();
144      if (copyFrom.properties != null)
145         for (Map.Entry<String,SchemaInfo> e : copyFrom.properties.entrySet())
146            this.properties.put(e.getKey(), e.getValue().copy());
147
148      this.additionalProperties = copyFrom.additionalProperties == null ? null : copyFrom.additionalProperties.copy();
149   }
150
151   /**
152    * Make a deep copy of this object.
153    *
154    * @return A deep copy of this object.
155    */
156   public SchemaInfo copy() {
157      return new SchemaInfo(this);
158   }
159
160   /**
161    * Bean property getter:  <property>format</property>.
162    *
163    * <h5 class='section'>See Also:</h5>
164    * <ul>
165    *    <li class='extlink'>{@doc SwaggerDataTypeFormats}
166    * </ul>
167    *
168    * @return The property value, or <jk>null</jk> if it is not set.
169    */
170   public String getFormat() {
171      return format;
172   }
173
174   /**
175    * Bean property setter:  <property>format</property>.
176    *
177    * <h5 class='section'>See Also:</h5>
178    * <ul class='doctree'>
179    *    <li class='extlink'>{@doc SwaggerDataTypes}
180    * </ul>
181    *
182    * @param value
183    *    The new value for this property.
184    *    <br>Can be <jk>null</jk> to unset the property.
185    *    <br>Formats defined by the OAS include:
186    *    <ul>
187    *       <li><js>"int32"</js>
188    *       <li><js>"int64"</js>
189    *       <li><js>"float"</js>
190    *       <li><js>"double"</js>
191    *       <li><js>"byte"</js>
192    *       <li><js>"binary"</js>
193    *       <li><js>"date"</js>
194    *       <li><js>"date-time"</js>
195    *       <li><js>"password"</js>
196    *    </ul>
197    * @return This object (for method chaining).
198    */
199   public SchemaInfo setFormat(String value) {
200      format = value;
201      return this;
202   }
203
204   /**
205    * Same as {@link #setFormat(String)}.
206    *
207    * @param value
208    *    The new value for this property.
209    *    <br>Non-String values will be converted to String using <code>toString()</code>.
210    *    <br>Can be <jk>null</jk> to unset the property.
211    * @return This object (for method chaining).
212    */
213   public SchemaInfo format(Object value) {
214      return setFormat(toStringVal(value));
215   }
216
217   /**
218    * Bean property getter:  <property>title</property>.
219    *
220    * @return The property value, or <jk>null</jk> if it is not set.
221    */
222   public String getTitle() {
223      return title;
224   }
225
226   /**
227    * Bean property setter:  <property>title</property>.
228    *
229    * @param value
230    *    The new value for this property.
231    *    <br>Can be <jk>null</jk> to unset the property.
232    * @return This object (for method chaining).
233    */
234   public SchemaInfo setTitle(String value) {
235      title = value;
236      return this;
237   }
238
239   /**
240    * Same as {@link #setTitle(String)}.
241    *
242    * @param value
243    *    The new value for this property.
244    *    <br>Non-String values will be converted to String using <code>toString()</code>.
245    *    <br>Can be <jk>null</jk> to unset the property.
246    * @return This object (for method chaining).
247    */
248   public SchemaInfo title(Object value) {
249      return setTitle(toStringVal(value));
250   }
251
252   /**
253    * Bean property getter:  <property>description</property>.
254    *
255    * @return The property value, or <jk>null</jk> if it is not set.
256    */
257   public String getDescription() {
258      return description;
259   }
260
261   /**
262    * Bean property setter:  <property>description</property>.
263    *
264    * @param value
265    *    The new value for this property.
266    *    <br>{@doc GFM} can be used for rich text representation.
267    *    <br>Can be <jk>null</jk> to unset the property.
268    * @return This object (for method chaining).
269    */
270   public SchemaInfo setDescription(String value) {
271      description = value;
272      return this;
273   }
274
275   /**
276    * Same as {@link #setDescription(String)}.
277    *
278    * @param value
279    *    The new value for this property.
280    *    <br>Non-String values will be converted to String using <code>toString()</code>.
281    *    <br>Can be <jk>null</jk> to unset the property.
282    * @return This object (for method chaining).
283    */
284   public SchemaInfo description(Object value) {
285      return setDescription(toStringVal(value));
286   }
287
288   /**
289    * Bean property getter:  <property>default</property>.
290    *
291    * <p>
292    * Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object.
293    *
294    * @return The property value, or <jk>null</jk> if it is not set.
295    */
296   public Object getDefault() {
297      return _default;
298   }
299
300   /**
301    * Bean property setter:  <property>default</property>.
302    *
303    * <p>
304    * Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object.
305    *
306    * @param value
307    *    The new value for this property.
308    *    <br>Can be <jk>null</jk> to unset the property.
309    * @return This object (for method chaining).
310    */
311   public SchemaInfo setDefault(Object value) {
312      _default = value;
313      return this;
314   }
315
316   /**
317    * Same as {@link #setDefault(Object)}.
318    *
319    * @param value The new value for this property.
320    * @return This object (for method chaining).
321    */
322   public SchemaInfo _default(Object value) {
323      return setDefault(value);
324   }
325
326   /**
327    * Bean property getter:  <property>multipleOf</property>.
328    *
329    * @return The property value, or <jk>null</jk> if it is not set.
330    */
331   public Number getMultipleOf() {
332      return multipleOf;
333   }
334
335   /**
336    * Bean property setter:  <property>multipleOf</property>.
337    *
338    * @param value
339    *    The new value for this property.
340    *    <br>Can be <jk>null</jk> to unset the property.
341    * @return This object (for method chaining).
342    */
343   public SchemaInfo setMultipleOf(Number value) {
344      multipleOf = value;
345      return this;
346   }
347
348   /**
349    * Same as {@link #setMultipleOf(Number)}.
350    *
351    * @param value
352    *    The new value for this property.
353    *    <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match.
354    *    <br>Can be <jk>null</jk> to unset the property.
355    * @return This object (for method chaining).
356    */
357   public SchemaInfo multipleOf(Object value) {
358      return setMultipleOf(toNumber(value));
359   }
360
361   /**
362    * Bean property getter:  <property>maximum</property>.
363    *
364    * @return The property value, or <jk>null</jk> if it is not set.
365    */
366   public Number getMaximum() {
367      return maximum;
368   }
369
370   /**
371    * Bean property setter:  <property>maximum</property>.
372    *
373    * @param value
374    *    The new value for this property.
375    *    <br>Can be <jk>null</jk> to unset the property.
376    * @return This object (for method chaining).
377    */
378   public SchemaInfo setMaximum(Number value) {
379      maximum = value;
380      return this;
381   }
382
383   /**
384    * Same as {@link #setMaximum(Number)}.
385    *
386    * @param value
387    *    The new value for this property.
388    *    <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match.
389    *    <br>Can be <jk>null</jk> to unset the property.
390    * @return This object (for method chaining).
391    */
392   public SchemaInfo maximum(Object value) {
393      return setMaximum(toNumber(value));
394   }
395
396   /**
397    * Bean property getter:  <property>exclusiveMaximum</property>.
398    *
399    * @return The property value, or <jk>null</jk> if it is not set.
400    */
401   public Boolean getExclusiveMaximum() {
402      return exclusiveMaximum;
403   }
404
405   /**
406    * Bean property setter:  <property>exclusiveMaximum</property>.
407    *
408    * @param value
409    *    The new value for this property.
410    *    <br>Can be <jk>null</jk> to unset the property.
411    * @return This object (for method chaining).
412    */
413   public SchemaInfo setExclusiveMaximum(Boolean value) {
414      exclusiveMaximum = value;
415      return this;
416   }
417
418   /**
419    * Same as {@link #setExclusiveMaximum(Boolean)}.
420    *
421    * @param value
422    *    The new value for this property.
423    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
424    *    <br>Can be <jk>null</jk> to unset the property.
425    * @return This object (for method chaining).
426    */
427   public SchemaInfo exclusiveMaximum(Object value) {
428      return setExclusiveMaximum(toBoolean(value));
429   }
430
431   /**
432    * Bean property getter:  <property>minimum</property>.
433    *
434    * @return The property value, or <jk>null</jk> if it is not set.
435    */
436   public Number getMinimum() {
437      return minimum;
438   }
439
440   /**
441    * Bean property setter:  <property>minimum</property>.
442    *
443    * @param value
444    *    The new value for this property.
445    *    <br>Can be <jk>null</jk> to unset the property.
446    * @return This object (for method chaining).
447    */
448   public SchemaInfo setMinimum(Number value) {
449      minimum = value;
450      return this;
451   }
452
453   /**
454    * Same as {@link #setMinimum(Number)}.
455    *
456    * @param value
457    *    The new value for this property.
458    *    <br>Non-Number values will be converted to Number using <code>toString()</code> then best number match.
459    *    <br>Can be <jk>null</jk> to unset the property.
460    * @return This object (for method chaining).
461    */
462   public SchemaInfo minimum(Object value) {
463      return setMinimum(toNumber(value));
464   }
465
466   /**
467    * Bean property getter:  <property>exclusiveMinimum</property>.
468    *
469    * @return The property value, or <jk>null</jk> if it is not set.
470    */
471   public Boolean getExclusiveMinimum() {
472      return exclusiveMinimum;
473   }
474
475   /**
476    * Bean property setter:  <property>exclusiveMinimum</property>.
477    *
478    * @param value
479    *    The new value for this property.
480    *    <br>Can be <jk>null</jk> to unset the property.
481    * @return This object (for method chaining).
482    */
483   public SchemaInfo setExclusiveMinimum(Boolean value) {
484      exclusiveMinimum = value;
485      return this;
486   }
487
488   /**
489    * Same as {@link #setExclusiveMinimum(Boolean)}.
490    *
491    * @param value
492    *    The new value for this property.
493    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
494    *    <br>Can be <jk>null</jk> to unset the property.
495    * @return This object (for method chaining).
496    */
497   public SchemaInfo exclusiveMinimum(Object value) {
498      return setExclusiveMinimum(toBoolean(value));
499   }
500
501   /**
502    * Bean property getter:  <property>maxLength</property>.
503    *
504    * @return The property value, or <jk>null</jk> if it is not set.
505    */
506   public Integer getMaxLength() {
507      return maxLength;
508   }
509
510   /**
511    * Bean property setter:  <property>maxLength</property>.
512    *
513    * @param value
514    *    The new value for this property.
515    *    <br>Can be <jk>null</jk> to unset the property.
516    * @return This object (for method chaining).
517    */
518   public SchemaInfo setMaxLength(Integer value) {
519      maxLength = value;
520      return this;
521   }
522
523   /**
524    * Same as {@link #setMaxLength(Integer)}.
525    *
526    * @param value
527    *    The new value for this property.
528    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
529    *    <br>Can be <jk>null</jk> to unset the property.
530    * @return This object (for method chaining).
531    */
532   public SchemaInfo maxLength(Object value) {
533      return setMaxLength(toInteger(value));
534   }
535
536   /**
537    * Bean property getter:  <property>minLength</property>.
538    *
539    * @return The property value, or <jk>null</jk> if it is not set.
540    */
541   public Integer getMinLength() {
542      return minLength;
543   }
544
545   /**
546    * Bean property setter:  <property>minLength</property>.
547    *
548    * @param value
549    *    The new value for this property.
550    *    <br>Can be <jk>null</jk> to unset the property.
551    * @return This object (for method chaining).
552    */
553   public SchemaInfo setMinLength(Integer value) {
554      minLength = value;
555      return this;
556   }
557
558   /**
559    * Same as {@link #setMinLength(Integer)}.
560    *
561    * @param value
562    *    The new value for this property.
563    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
564    *    <br>Can be <jk>null</jk> to unset the property.
565    * @return This object (for method chaining).
566    */
567   public SchemaInfo minLength(Object value) {
568      return setMinLength(toInteger(value));
569   }
570
571   /**
572    * Bean property getter:  <property>pattern</property>.
573    *
574    * @return The property value, or <jk>null</jk> if it is not set.
575    */
576   public String getPattern() {
577      return pattern;
578   }
579
580   /**
581    * Bean property setter:  <property>pattern</property>.
582    *
583    * <p>
584    * This string SHOULD be a valid regular expression.
585    *
586    * @param value
587    *    The new value for this property.
588    *    <br>Can be <jk>null</jk> to unset the property.
589    * @return This object (for method chaining).
590    */
591   public SchemaInfo setPattern(String value) {
592      pattern = value;
593      return this;
594   }
595
596   /**
597    * Same as {@link #setPattern(String)}.
598    *
599    * @param value
600    *    The new value for this property.
601    *    <br>Non-String values will be converted to String using <code>toString()</code>.
602    *    <br>Can be <jk>null</jk> to unset the property.
603    * @return This object (for method chaining).
604    */
605   public SchemaInfo pattern(Object value) {
606      return setPattern(toStringVal(value));
607   }
608
609   /**
610    * Bean property getter:  <property>maxItems</property>.
611    *
612    * @return The property value, or <jk>null</jk> if it is not set.
613    */
614   public Integer getMaxItems() {
615      return maxItems;
616   }
617
618   /**
619    * Bean property setter:  <property>maxItems</property>.
620    *
621    * @param value
622    *    The new value for this property.
623    *    <br>Can be <jk>null</jk> to unset the property.
624    * @return This object (for method chaining).
625    */
626   public SchemaInfo setMaxItems(Integer value) {
627      maxItems = value;
628      return this;
629   }
630
631   /**
632    * Same as {@link #setMaxItems(Integer)}.
633    *
634    * @param value
635    *    The new value for this property.
636    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
637    *    <br>Can be <jk>null</jk> to unset the property.
638    * @return This object (for method chaining).
639    */
640   public SchemaInfo maxItems(Object value) {
641      return setMaxItems(toInteger(value));
642   }
643
644   /**
645    * Bean property getter:  <property>minItems</property>.
646    *
647    * @return The property value, or <jk>null</jk> if it is not set.
648    */
649   public Integer getMinItems() {
650      return minItems;
651   }
652
653   /**
654    * Bean property setter:  <property>minItems</property>.
655    *
656    * @param value
657    *    The new value for this property.
658    *    <br>Can be <jk>null</jk> to unset the property.
659    * @return This object (for method chaining).
660    */
661   public SchemaInfo setMinItems(Integer value) {
662      minItems = value;
663      return this;
664   }
665
666   /**
667    * Same as {@link #setMinItems(Integer)}.
668    *
669    * @param value
670    *    The new value for this property.
671    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
672    *    <br>Can be <jk>null</jk> to unset the property.
673    * @return This object (for method chaining).
674    */
675   public SchemaInfo minItems(Object value) {
676      return setMinItems(toInteger(value));
677   }
678
679   /**
680    * Bean property getter:  <property>uniqueItems</property>.
681    *
682    * @return The property value, or <jk>null</jk> if it is not set.
683    */
684   public Boolean getUniqueItems() {
685      return uniqueItems;
686   }
687   /**
688    * Bean property setter:  <property>uniqueItems</property>.
689    *
690    * @param value
691    *    The new value for this property.
692    *    <br>Can be <jk>null</jk> to unset the property.
693    * @return This object (for method chaining).
694    */
695   public SchemaInfo setUniqueItems(Boolean value) {
696      uniqueItems = value;
697      return this;
698   }
699
700   /**
701    * Same as {@link #setUniqueItems(Boolean)}.
702    *
703    * @param value
704    *    The new value for this property.
705    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
706    *    <br>Can be <jk>null</jk> to unset the property.
707    * @return This object (for method chaining).
708    */
709   public SchemaInfo uniqueItems(Object value) {
710      return setUniqueItems(toBoolean(value));
711   }
712
713   /**
714    * Bean property getter:  <property>maxProperties</property>.
715    *
716    * @return The property value, or <jk>null</jk> if it is not set.
717    */
718   public Integer getMaxProperties() {
719      return maxProperties;
720   }
721
722   /**
723    * Bean property setter:  <property>maxProperties</property>.
724    *
725    * @param value
726    *    The new value for this property.
727    *    <br>Can be <jk>null</jk> to unset the property.
728    * @return This object (for method chaining).
729    */
730   public SchemaInfo setMaxProperties(Integer value) {
731      maxProperties = value;
732      return this;
733   }
734
735   /**
736    * Same as {@link #setMaxProperties(Integer)}.
737    *
738    * @param value
739    *    The new value for this property.
740    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
741    *    <br>Can be <jk>null</jk> to unset the property.
742    * @return This object (for method chaining).
743    */
744   public SchemaInfo maxProperties(Object value) {
745      return setMaxProperties(toInteger(value));
746   }
747
748   /**
749    * Bean property getter:  <property>minProperties</property>.
750    *
751    * @return The property value, or <jk>null</jk> if it is not set.
752    */
753   public Integer getMinProperties() {
754      return minProperties;
755   }
756
757   /**
758    * Bean property setter:  <property>minProperties</property>.
759    *
760    * @param value
761    *    The new value for this property.
762    *    <br>Can be <jk>null</jk> to unset the property.
763    * @return This object (for method chaining).
764    */
765   public SchemaInfo setMinProperties(Integer value) {
766      minProperties = value;
767      return this;
768   }
769
770   /**
771    * Same as {@link #setMinProperties(Integer)}.
772    *
773    * @param value
774    *    The new value for this property.
775    *    <br>Non-Integer values will be converted to Integer using <code>Integer.<jsm>valueOf</jsm>(value.toString())</code>.
776    *    <br>Can be <jk>null</jk> to unset the property.
777    * @return This object (for method chaining).
778    */
779   public SchemaInfo minProperties(Object value) {
780      return setMinProperties(toInteger(value));
781   }
782
783   /**
784    * Bean property getter:  <property>required</property>.
785    *
786    * <p>
787    * The list of required properties.
788    *
789    * @return The property value, or <jk>null</jk> if it is not set.
790    */
791   public List<String> getRequired() {
792      return required;
793   }
794
795   /**
796    * Bean property setter:  <property>required</property>.
797    *
798    * <p>
799    * The list of required properties.
800    *
801    * @param value
802    *    The new value for this property.
803    *    <br>Valid values:
804    *    <ul>
805    *       <li><js>"http"</js>
806    *       <li><js>"https"</js>
807    *       <li><js>"ws"</js>
808    *       <li><js>"wss"</js>
809    *    </ul>
810    *    <br>Can be <jk>null</jk> to unset the property.
811    * @return This object (for method chaining).
812    */
813   public SchemaInfo setRequired(Collection<String> value) {
814      required = newList(value);
815      return this;
816   }
817
818   /**
819    * Adds one or more values to the <property>required</property> property.
820    *
821    * <p>
822    * The list of required properties.
823    *
824    * @param value
825    *    The values to add to this property.
826    *    <br>Ignored if <jk>null</jk>.
827    * @return This object (for method chaining).
828    */
829   public SchemaInfo addRequired(Collection<String> value) {
830      required = addToList(required, value);
831      return this;
832   }
833
834   /**
835    * Same as {@link #addRequired(Collection)}.
836    *
837    * @param values
838    *    The new value for this property.
839    *    <br>Valid types:
840    *    <ul>
841    *       <li><code>Collection&lt;String&gt;</code>
842    *       <li><code>String</code> - JSON array representation of <code>Collection&lt;String&gt;</code>
843    *          <h5 class='figure'>Example:</h5>
844    *          <p class='bcode w800'>
845    *    schemes(<js>"['scheme1','scheme2']"</js>);
846    *          </p>
847    *       <li><code>String</code> - Individual values
848    *          <h5 class='figure'>Example:</h5>
849    *          <p class='bcode w800'>
850    *    schemes(<js>"scheme1</js>, <js>"scheme2"</js>);
851    *          </p>
852    *    </ul>
853    * @return This object (for method chaining).
854    */
855   public SchemaInfo required(Object...values) {
856      required = addToList(required, values, String.class);
857      return this;
858   }
859
860   /**
861    * Bean property getter:  <property>enum</property>.
862    *
863    * @return The property value, or <jk>null</jk> if it is not set.
864    */
865   public List<Object> getEnum() {
866      return _enum;
867   }
868
869   /**
870    * Bean property setter:  <property>enum</property>.
871    *
872    * <h5 class='section'>See Also:</h5>
873    * <ul>
874    *    <li class='extlink'>{@doc JsonSchemaValidation}
875    * </ul>
876    *
877    * @param value
878    *    The new value for this property.
879    *    <br>Can be <jk>null</jk> to unset the property.
880    * @return This object (for method chaining).
881    */
882   public SchemaInfo setEnum(Collection<Object> value) {
883      _enum = newList(value);
884      return this;
885   }
886
887   /**
888    * Adds one or more values to the <property>enum</property> property.
889    *
890    * @param value
891    *    The values to add to this property.
892    *    <br>Ignored if <jk>null</jk>.
893    * @return This object (for method chaining).
894    */
895   public SchemaInfo addEnum(Collection<Object> value) {
896      _enum = addToList(_enum, value);
897      return this;
898   }
899
900   /**
901    * Adds one or more values to the <property>enum</property> property.
902    *
903    * @param values
904    *    The values to add to this property.
905    *    <br>Valid types:
906    *    <ul>
907    *       <li><code>Object</code>
908    *       <li><code>Collection&lt;Object&gt;</code>
909    *       <li><code>String</code> - JSON array representation of <code>Collection&lt;Object&gt;</code>
910    *          <h5 class='figure'>Example:</h5>
911    *          <p class='bcode w800'>
912    *    _enum(<js>"['foo','bar']"</js>);
913    *          </p>
914    *       <li><code>String</code> - Individual values
915    *          <h5 class='figure'>Example:</h5>
916    *          <p class='bcode w800'>
917    *    _enum(<js>"foo"</js>, <js>"bar"</js>);
918    *          </p>
919    *    </ul>
920    *    <br>Ignored if <jk>null</jk>.
921    * @return This object (for method chaining).
922    */
923   public SchemaInfo _enum(Object...values) {
924      _enum = addToList(_enum, values, Object.class);
925      return this;
926   }
927
928   /**
929    * Bean property getter:  <property>type</property>.
930    *
931    * @return The property value, or <jk>null</jk> if it is not set.
932    */
933   public String getType() {
934      return type;
935   }
936
937   /**
938    * Bean property setter:  <property>type</property>.
939    *
940    * <h5 class='section'>See Also:</h5>
941    * <ul class='doctree'>
942    *    <li class='extlink'>{@doc SwaggerDataTypes}
943    * </ul>
944    *
945    * @param value
946    *    The new value for this property.
947    *    <br>Can be <jk>null</jk> to unset the property.
948    *    <br>Possible values include:
949    *    <ul>
950    *       <li><js>"object"</js>
951    *       <li><js>"string"</js>
952    *       <li><js>"number"</js>
953    *       <li><js>"integer"</js>
954    *       <li><js>"boolean"</js>
955    *       <li><js>"array"</js>
956    *       <li><js>"file"</js>
957    *    </ul>
958    * @return This object (for method chaining).
959    */
960   public SchemaInfo setType(String value) {
961      type = value;
962      return this;
963   }
964
965   /**
966    * Same as {@link #setType(String)}.
967    *
968    * @param value
969    *    The new value for this property.
970    *    <br>Non-String values will be converted to String using <code>toString()</code>.
971    *    <br>Can be <jk>null</jk> to unset the property.
972    * @return This object (for method chaining).
973    */
974   public SchemaInfo type(Object value) {
975      return setType(toStringVal(value));
976   }
977
978   /**
979    * Bean property getter:  <property>items</property>.
980    *
981    * @return The property value, or <jk>null</jk> if it is not set.
982    */
983   public Items getItems() {
984      return items;
985   }
986
987   /**
988    * Bean property setter:  <property>items</property>.
989    *
990    * @param value
991    *    The new value for this property.
992    *    <br>Can be <jk>null</jk> to unset the property.
993    * @return This object (for method chaining).
994    */
995   public SchemaInfo setItems(Items value) {
996      items = value;
997      return this;
998   }
999
1000   /**
1001    * Same as {@link #setItems(Items)}.
1002    *
1003    * @param value
1004    *    The new value for this property.
1005    *    <br>Valid types:
1006    *    <ul>
1007    *       <li>{@link Items}
1008    *       <li><code>String</code> - JSON object representation of {@link Items}
1009    *          <h5 class='figure'>Example:</h5>
1010    *          <p class='bcode w800'>
1011    *    items(<js>"{type:'type',format:'format',...}"</js>);
1012    *          </p>
1013    *    </ul>
1014    *    <br>Can be <jk>null</jk> to unset the property.
1015    * @return This object (for method chaining).
1016    */
1017   public SchemaInfo items(Object value) {
1018      return setItems(toType(value, Items.class));
1019   }
1020
1021   /**
1022    * Bean property getter:  <property>allOf</property>.
1023    *
1024    * @return The property value, or <jk>null</jk> if it is not set.
1025    */
1026   public List<Object> getAllOf() {
1027      return allOf;
1028   }
1029
1030   /**
1031    * Bean property setter:  <property>allOf</property>.
1032    *
1033    * @param value
1034    *    The new value for this property.
1035    *    <br>Can be <jk>null</jk> to unset the property.
1036    * @return This object (for method chaining).
1037    */
1038   public SchemaInfo setAllOf(Collection<Object> value) {
1039      allOf = newList(value);
1040      return this;
1041   }
1042
1043   /**
1044    * Adds one or more values to the <property>allOf</property> property.
1045    *
1046    * @param values
1047    *    The values to add to this property.
1048    *    <br>Ignored if <jk>null</jk>.
1049    * @return This object (for method chaining).
1050    */
1051   public SchemaInfo addAllOf(Collection<Object> values) {
1052      allOf = addToList(allOf, values);
1053      return this;
1054   }
1055
1056   /**
1057    * Adds one or more values to the <property>allOf</property> property.
1058    *
1059    * @param values
1060    *    The values to add to this property.
1061    *    <br>Valid types:
1062    *    <ul>
1063    *       <li><code>Object</code>
1064    *       <li><code>Collection&lt;Object&gt;</code>
1065    *       <li><code>String</code> - JSON array representation of <code>Collection&lt;Object&gt;</code>
1066    *          <h5 class='figure'>Example:</h5>
1067    *          <p class='bcode w800'>
1068    *    allOf(<js>"['foo','bar']"</js>);
1069    *          </p>
1070    *       <li><code>String</code> - Individual values
1071    *          <h5 class='figure'>Example:</h5>
1072    *          <p class='bcode w800'>
1073    *    allOf(<js>"foo"</js>, <js>"bar"</js>);
1074    *          </p>
1075    *    </ul>
1076    *    <br>Ignored if <jk>null</jk>.
1077    * @return This object (for method chaining).
1078    */
1079   public SchemaInfo allOf(Object...values) {
1080      allOf = addToList(allOf, values, Object.class);
1081      return this;
1082   }
1083
1084   /**
1085    * Bean property getter:  <property>properties</property>.
1086    *
1087    * @return The property value, or <jk>null</jk> if it is not set.
1088    */
1089   public Map<String,SchemaInfo> getProperties() {
1090      return properties;
1091   }
1092
1093   /**
1094    * Bean property setter:  <property>properties</property>.
1095    *
1096    * @param value
1097    *    The new value for this property.
1098    *    <br>Can be <jk>null</jk> to unset the property.
1099    * @return This object (for method chaining).
1100    */
1101   public SchemaInfo setProperties(Map<String,SchemaInfo> value) {
1102      properties = newMap(value);
1103      return this;
1104   }
1105
1106   /**
1107    * Adds one or more values to the <property>properties</property> property.
1108    *
1109    * @param values
1110    *    The values to add to this property.
1111    *    <br>Ignored if <jk>null</jk>.
1112    * @return This object (for method chaining).
1113    */
1114   public SchemaInfo addProperties(Map<String,SchemaInfo> values) {
1115      properties = addToMap(properties, values);
1116      return this;
1117   }
1118
1119   /**
1120    * Adds one or more values to the <property>properties</property> property.
1121    *
1122    * @param values
1123    *    The values to add to this property.
1124    *    <br>Valid types:
1125    *    <ul>
1126    *       <li><code>Map&lt;String,Map&lt;String,Object&gt;&gt;</code>
1127    *       <li><code>String</code> - JSON object representation of <code>Map&lt;String,Map&lt;String,Object&gt;&gt;</code>
1128    *          <h5 class='figure'>Example:</h5>
1129    *          <p class='bcode w800'>
1130    *    properties(<js>"{name:{foo:'bar'}}"</js>);
1131    *          </p>
1132    *    </ul>
1133    *    <br>Ignored if <jk>null</jk>.
1134    * @return This object (for method chaining).
1135    */
1136   public SchemaInfo properties(Object...values) {
1137      properties = addToMap(properties, values, String.class, SchemaInfo.class);
1138      return this;
1139   }
1140
1141   /**
1142    * Bean property getter:  <property>additionalProperties</property>.
1143    *
1144    * @return The property value, or <jk>null</jk> if it is not set.
1145    */
1146   public SchemaInfo getAdditionalProperties() {
1147      return additionalProperties;
1148   }
1149
1150   /**
1151    * Bean property setter:  <property>additionalProperties</property>.
1152    *
1153    * @param value
1154    *    The new value for this property.
1155    *    <br>Can be <jk>null</jk> to unset the property.
1156    * @return This object (for method chaining).
1157    */
1158   public SchemaInfo setAdditionalProperties(SchemaInfo value) {
1159      additionalProperties = value;
1160      return this;
1161   }
1162
1163   /**
1164    * Bean property setter:  <property>additionalProperties</property>.
1165    *
1166    * @param value
1167    *    The new value for this property.
1168    *    <br>Can be <jk>null</jk> to unset the property.
1169    * @return This object (for method chaining).
1170    */
1171   public SchemaInfo additionalProperties(Object value) {
1172      additionalProperties = toType(value, SchemaInfo.class);
1173      return this;
1174   }
1175
1176   /**
1177    * Bean property getter:  <property>discriminator</property>.
1178    *
1179    * @return The property value, or <jk>null</jk> if it is not set.
1180    */
1181   public String getDiscriminator() {
1182      return discriminator;
1183   }
1184
1185   /**
1186    * Bean property setter:  <property>discriminator</property>.
1187    *
1188    * @param value
1189    *    The new value for this property.
1190    *    <br>Can be <jk>null</jk> to unset the property.
1191    * @return This object (for method chaining).
1192    */
1193   public SchemaInfo setDiscriminator(String value) {
1194      discriminator = value;
1195      return this;
1196   }
1197
1198   /**
1199    * Same as {@link #setDiscriminator(String)}.
1200    *
1201    * @param value
1202    *    The new value for this property.
1203    *    <br>Non-String values will be converted to String using <code>toString()</code>.
1204    *    <br>Can be <jk>null</jk> to unset the property.
1205    * @return This object (for method chaining).
1206    */
1207   public SchemaInfo discriminator(Object value) {
1208      return setDiscriminator(toStringVal(value));
1209   }
1210
1211   /**
1212    * Bean property getter:  <property>readOnly</property>.
1213    *
1214    * @return The property value, or <jk>null</jk> if it is not set.
1215    */
1216   public Boolean getReadOnly() {
1217      return readOnly;
1218   }
1219
1220   /**
1221    * Bean property setter:  <property>readOnly</property>.
1222    *
1223    * @param value
1224    *    The new value for this property.
1225    *    <br>Can be <jk>null</jk> to unset the property.
1226    * @return This object (for method chaining).
1227    */
1228   public SchemaInfo setReadOnly(Boolean value) {
1229      readOnly = value;
1230      return this;
1231   }
1232
1233   /**
1234    * Same as {@link #setReadOnly(Boolean)}.
1235    *
1236    * @param value
1237    *    The new value for this property.
1238    *    <br>Non-boolean values will be converted to boolean using <code>Boolean.<jsm>valueOf</jsm>(value.toString())</code>.
1239    *    <br>Can be <jk>null</jk> to unset the property.
1240    * @return This object (for method chaining).
1241    */
1242   public SchemaInfo readOnly(Object value) {
1243      return setReadOnly(toBoolean(value));
1244   }
1245
1246   /**
1247    * Bean property getter:  <property>xml</property>.
1248    *
1249    * @return The property value, or <jk>null</jk> if it is not set.
1250    */
1251   public Xml getXml() {
1252      return xml;
1253   }
1254
1255   /**
1256    * Bean property setter:  <property>xml</property>.
1257    *
1258    * @param value
1259    *    The new value for this property.
1260    *    <br>Can be <jk>null</jk> to unset the property.
1261    * @return This object (for method chaining).
1262    */
1263   public SchemaInfo setXml(Xml value) {
1264      xml = value;
1265      return this;
1266   }
1267
1268   /**
1269    * Same as {@link #setXml(Xml)}.
1270    *
1271    * @param value
1272    *    The new value for this property.
1273    *    <br>Valid types:
1274    *    <ul>
1275    *       <li>{@link Xml}
1276    *       <li><code>String</code> - JSON object representation of {@link Xml}
1277    *          <h5 class='figure'>Example:</h5>
1278    *          <p class='bcode w800'>
1279    *    xml(<js>"{name:'name',namespace:'namespace',...}"</js>);
1280    *          </p>
1281    *    </ul>
1282    *    <br>Can be <jk>null</jk> to unset the property.
1283    * @return This object (for method chaining).
1284    */
1285   public SchemaInfo xml(Object value) {
1286      return setXml(toType(value, Xml.class));
1287   }
1288
1289   /**
1290    * Bean property getter:  <property>externalDocs</property>.
1291    *
1292    * @return The property value, or <jk>null</jk> if it is not set.
1293    */
1294   public ExternalDocumentation getExternalDocs() {
1295      return externalDocs;
1296   }
1297
1298   /**
1299    * Bean property setter:  <property>externalDocs</property>.
1300    *
1301    * @param value
1302    *    The new value for this property.
1303    *    <br>Can be <jk>null</jk> to unset the property.
1304    * @return This object (for method chaining).
1305    */
1306   public SchemaInfo setExternalDocs(ExternalDocumentation value) {
1307      externalDocs = value;
1308      return this;
1309   }
1310
1311   /**
1312    * Same as {@link #setExternalDocs(ExternalDocumentation)}.
1313    *
1314    * @param value
1315    *    The new value for this property.
1316    *    <br>Valid types:
1317    *    <ul>
1318    *       <li>{@link ExternalDocumentation}
1319    *       <li><code>String</code> - JSON object representation of {@link ExternalDocumentation}
1320    *          <h5 class='figure'>Example:</h5>
1321    *          <p class='bcode w800'>
1322    *    externalDocs(<js>"{description:'description',url:'url'}"</js>);
1323    *          </p>
1324    *    </ul>
1325    *    <br>Can be <jk>null</jk> to unset the property.
1326    * @return This object (for method chaining).
1327    */
1328   public SchemaInfo externalDocs(Object value) {
1329      return setExternalDocs(toType(value, ExternalDocumentation.class));
1330   }
1331
1332   /**
1333    * Bean property getter:  <property>example</property>.
1334    *
1335    * @return The property value, or <jk>null</jk> if it is not set.
1336    */
1337   public Object getExample() {
1338      return example;
1339   }
1340
1341   /**
1342    * Bean property setter:  <property>example</property>.
1343    *
1344    * @param value
1345    *    The new value for this property.
1346    *    <br>Can be <jk>null</jk> to unset the property.
1347    * @return This object (for method chaining).
1348    */
1349   public SchemaInfo setExample(Object value) {
1350      example = value;
1351      return this;
1352   }
1353
1354   /**
1355    * Same as {@link #setExample(Object)}.
1356    *
1357    * @param value
1358    *    The new value for this property.
1359    *    <br>Can be <jk>null</jk> to unset the property.
1360    * @return This object (for method chaining).
1361    */
1362   public SchemaInfo example(Object value) {
1363      return setExample(value);
1364   }
1365
1366   /**
1367    * Bean property getter:  <property>$ref</property>.
1368    *
1369    * @return The property value, or <jk>null</jk> if it is not set.
1370    */
1371   @BeanProperty("$ref")
1372   public String getRef() {
1373      return ref;
1374   }
1375
1376   /**
1377    * Returns <jk>true</jk> if this object has a <js>"$ref"</js> attribute.
1378    *
1379    * @return <jk>true</jk> if this object has a <js>"$ref"</js> attribute.
1380    */
1381   public boolean hasRef() {
1382      return ref != null;
1383   }
1384
1385   /**
1386    * Bean property setter:  <property>$ref</property>.
1387    *
1388    * @param value
1389    *    The new value for this property.
1390    *    <br>Can be <jk>null</jk> to unset the property.
1391    * @return This object (for method chaining).
1392    */
1393   @BeanProperty("$ref")
1394   public SchemaInfo setRef(Object value) {
1395      ref = StringUtils.asString(value);
1396      return this;
1397   }
1398
1399   /**
1400    * Same as {@link #setRef(Object)}.
1401    *
1402    * @param value
1403    *    The new value for this property.
1404    *    <br>Can be <jk>null</jk> to unset the property.
1405    * @return This object (for method chaining).
1406    */
1407   public SchemaInfo ref(Object value) {
1408      return setRef(value);
1409   }
1410
1411   @Override /* SwaggerElement */
1412   public <T> T get(String property, Class<T> type) {
1413      if (property == null)
1414         return null;
1415      switch (property) {
1416         case "format": return toType(getFormat(), type);
1417         case "title": return toType(getTitle(), type);
1418         case "description": return toType(getDescription(), type);
1419         case "default": return toType(getDefault(), type);
1420         case "multipleOf": return toType(getMultipleOf(), type);
1421         case "maximum": return toType(getMaximum(), type);
1422         case "exclusiveMaximum": return toType(getExclusiveMaximum(), type);
1423         case "minimum": return toType(getMinimum(), type);
1424         case "exclusiveMinimum": return toType(getExclusiveMinimum(), type);
1425         case "maxLength": return toType(getMaxLength(), type);
1426         case "minLength": return toType(getMinLength(), type);
1427         case "pattern": return toType(getPattern(), type);
1428         case "maxItems": return toType(getMaxItems(), type);
1429         case "minItems": return toType(getMinItems(), type);
1430         case "uniqueItems": return toType(getUniqueItems(), type);
1431         case "maxProperties": return toType(getMaxProperties(), type);
1432         case "minProperties": return toType(getMinProperties(), type);
1433         case "required": return toType(getRequired(), type);
1434         case "enum": return toType(getEnum(), type);
1435         case "type": return toType(getType(), type);
1436         case "items": return toType(getItems(), type);
1437         case "allOf": return toType(getAllOf(), type);
1438         case "properties": return toType(getProperties(), type);
1439         case "additionalProperties": return toType(getAdditionalProperties(), type);
1440         case "discriminator": return toType(getDiscriminator(), type);
1441         case "readOnly": return toType(getReadOnly(), type);
1442         case "xml": return toType(getXml(), type);
1443         case "externalDocs": return toType(getExternalDocs(), type);
1444         case "example": return toType(getExample(), type);
1445         case "$ref": return toType(getRef(), type);
1446         default: return super.get(property, type);
1447      }
1448   }
1449
1450   @Override /* SwaggerElement */
1451   public SchemaInfo set(String property, Object value) {
1452      if (property == null)
1453         return this;
1454      switch (property) {
1455         case "format": return format(value);
1456         case "title": return title(value);
1457         case "description": return description(value);
1458         case "default": return _default(value);
1459         case "multipleOf": return multipleOf(value);
1460         case "maximum": return maximum(value);
1461         case "exclusiveMaximum": return exclusiveMaximum(value);
1462         case "minimum": return minimum(value);
1463         case "exclusiveMinimum": return exclusiveMinimum(value);
1464         case "maxLength": return maxLength(value);
1465         case "minLength": return minLength(value);
1466         case "pattern": return pattern(value);
1467         case "maxItems": return maxItems(value);
1468         case "minItems": return minItems(value);
1469         case "uniqueItems": return uniqueItems(value);
1470         case "maxProperties": return maxProperties(value);
1471         case "minProperties": return minProperties(value);
1472         case "required": return setRequired(null).required(value);
1473         case "enum": return setEnum(null)._enum(value);
1474         case "type": return type(value);
1475         case "items": return items(value);
1476         case "allOf": return setAllOf(null).allOf(value);
1477         case "properties": return setProperties(null).properties(value);
1478         case "additionalProperties": return additionalProperties(value);
1479         case "discriminator": return discriminator(value);
1480         case "readOnly": return readOnly(value);
1481         case "xml": return xml(value);
1482         case "externalDocs": return externalDocs(value);
1483         case "example": return example(value);
1484         case "$ref": return ref(value);
1485         default:
1486            super.set(property, value);
1487            return this;
1488      }
1489   }
1490
1491   @Override /* SwaggerElement */
1492   public Set<String> keySet() {
1493      ASet<String> s = new ASet<String>()
1494         .appendIf(format != null, "format")
1495         .appendIf(title != null, "title")
1496         .appendIf(description != null, "description")
1497         .appendIf(_default != null, "default")
1498         .appendIf(multipleOf != null, "multipleOf")
1499         .appendIf(maximum != null, "maximum")
1500         .appendIf(exclusiveMaximum != null, "exclusiveMaximum")
1501         .appendIf(minimum != null, "minimum")
1502         .appendIf(exclusiveMinimum != null, "exclusiveMinimum")
1503         .appendIf(maxLength != null, "maxLength")
1504         .appendIf(minLength != null, "minLength")
1505         .appendIf(pattern != null, "pattern")
1506         .appendIf(maxItems != null, "maxItems")
1507         .appendIf(minItems != null, "minItems")
1508         .appendIf(uniqueItems != null, "uniqueItems")
1509         .appendIf(maxProperties != null, "maxProperties")
1510         .appendIf(minProperties != null, "minProperties")
1511         .appendIf(required != null, "required")
1512         .appendIf(_enum != null, "enum")
1513         .appendIf(type != null, "type")
1514         .appendIf(items != null, "items")
1515         .appendIf(allOf != null, "allOf")
1516         .appendIf(properties != null, "properties")
1517         .appendIf(additionalProperties != null, "additionalProperties")
1518         .appendIf(discriminator != null, "discriminator")
1519         .appendIf(readOnly != null, "readOnly")
1520         .appendIf(xml != null, "xml")
1521         .appendIf(externalDocs != null, "externalDocs")
1522         .appendIf(example != null, "example")
1523         .appendIf(ref != null, "$ref");
1524      return new MultiSet<>(s, super.keySet());
1525   }
1526
1527
1528
1529   /**
1530    * Returns <jk>true</jk> if this schema info has one or more properties defined on it.
1531    *
1532    * @return <jk>true</jk> if this schema info has one or more properties defined on it.
1533    */
1534   public boolean hasProperties() {
1535      return properties != null && ! properties.isEmpty();
1536   }
1537
1538   /**
1539    * Resolves any <js>"$ref"</js> attributes in this element.
1540    *
1541    * @param swagger The swagger document containing the definitions.
1542    * @param refStack Keeps track of previously-visited references so that we don't cause recursive loops.
1543    * @param maxDepth
1544    *    The maximum depth to resolve references.
1545    *    <br>After that level is reached, <code>$ref</code> references will be left alone.
1546    *    <br>Useful if you have very complex models and you don't want your swagger page to be overly-complex.
1547    * @return
1548    *    This object with references resolved.
1549    *    <br>May or may not be the same object.
1550    */
1551   public SchemaInfo resolveRefs(Swagger swagger, Deque<String> refStack, int maxDepth) {
1552
1553      if (ref != null) {
1554         if (refStack.contains(ref) || refStack.size() >= maxDepth)
1555            return this;
1556         refStack.addLast(ref);
1557         SchemaInfo r = swagger.findRef(ref, SchemaInfo.class).resolveRefs(swagger, refStack, maxDepth);
1558         refStack.removeLast();
1559         return r;
1560      }
1561
1562      if (items != null)
1563         items = items.resolveRefs(swagger, refStack, maxDepth);
1564
1565      if (properties != null)
1566         for (Map.Entry<String,SchemaInfo> e : properties.entrySet())
1567            e.setValue(e.getValue().resolveRefs(swagger, refStack, maxDepth));
1568
1569      if (additionalProperties != null)
1570         additionalProperties = additionalProperties.resolveRefs(swagger, refStack, maxDepth);
1571
1572      this.example = null;
1573
1574      return this;
1575   }
1576   
1577   /**
1578    * @deprecated Use {@link #setAdditionalProperties(SchemaInfo)}
1579    */
1580   @SuppressWarnings("javadoc")
1581   @Deprecated
1582   public SchemaInfo setAdditionalProperties(Map<String,Object> value) {
1583      return this;
1584   }
1585}