001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.swagger; 018 019import static org.apache.juneau.commons.utils.CollectionUtils.*; 020import static org.apache.juneau.bean.swagger.SwaggerCopyUtils.*; 021import static org.apache.juneau.commons.utils.Shorts.*; 022import static org.apache.juneau.marshall.internal.ConverterUtils.*; 023 024import java.util.*; 025 026import org.apache.juneau.commons.bean.*; 027import org.apache.juneau.commons.collections.*; 028import org.apache.juneau.marshall.marshaller.*; 029 030/** 031 * Describes a single HTTP header. 032 * 033 * <p> 034 * The Header Object follows the structure of the Parameter Object with the following changes: it does not have a 035 * <c>name</c> field since the header name is specified in the key, and it does not have a <c>required</c> field 036 * since headers are always optional in HTTP for Swagger 2.0. 037 * 038 * <h5 class='section'>Swagger Specification:</h5> 039 * <p> 040 * The Header Object is composed of the following fields: 041 * <ul class='spaced-list'> 042 * <li><c>description</c> (string) - A brief description of the header 043 * <li><c>type</c> (string, REQUIRED) - The type of the header. Values: <js>"string"</js>, <js>"number"</js>, <js>"integer"</js>, <js>"boolean"</js>, <js>"array"</js> 044 * <li><c>format</c> (string) - The format modifier (e.g., <js>"int32"</js>, <js>"int64"</js>, <js>"float"</js>, <js>"double"</js>, <js>"date"</js>, <js>"date-time"</js>) 045 * <li><c>items</c> ({@link Items}) - Required if type is <js>"array"</js>. Describes the type of items in the array 046 * <li><c>collectionFormat</c> (string) - How multiple values are formatted. Values: <js>"csv"</js>, <js>"ssv"</js>, <js>"tsv"</js>, <js>"pipes"</js>, <js>"multi"</js> 047 * <li><c>default</c> (any) - The default value 048 * <li><c>maximum</c> (number), <c>exclusiveMaximum</c> (boolean), <c>minimum</c> (number), <c>exclusiveMinimum</c> (boolean) - Numeric constraints 049 * <li><c>maxLength</c> (integer), <c>minLength</c> (integer), <c>pattern</c> (string) - String constraints 050 * <li><c>maxItems</c> (integer), <c>minItems</c> (integer), <c>uniqueItems</c> (boolean) - Array constraints 051 * <li><c>enum</c> (array) - Possible values for this header 052 * <li><c>multipleOf</c> (number) - Must be a multiple of this value 053 * </ul> 054 * 055 * <h5 class='section'>Example:</h5> 056 * <p class='bjava'> 057 * <jc>// Construct using SwaggerBuilder.</jc> 058 * HeaderInfo <jv>headerInfo</jv> = <jsm>headerInfo</jsm>(<js>"integer"</js>).description(<js>"The number of allowed requests in the current period"</js>); 059 * 060 * <jc>// Serialize using JsonSerializer.</jc> 061 * String <jv>json</jv> = Json.<jsm>from</jsm>(<jv>headerInfo</jv>); 062 * 063 * <jc>// Or just use toString() which does the same as above.</jc> 064 * <jv>json</jv> = <jv>headerInfo</jv>.toString(); 065 * </p> 066 * <p class='bjson'> 067 * <jc>// Output</jc> 068 * { 069 * <js>"description"</js>: <js>"The number of allowed requests in the current period"</js>, 070 * <js>"type"</js>: <js>"integer"</js> 071 * } 072 * </p> 073 * 074 * <h5 class='section'>See Also:</h5><ul> 075 * <li class='link'><a class="doclink" href="https://swagger.io/specification/v2/#header-object">Swagger 2.0 Specification > Header Object</a> 076 * <li class='link'><a class="doclink" href="https://swagger.io/docs/specification/2-0/describing-responses/">Swagger Describing Responses</a> 077 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanSwagger2">juneau-bean-swagger-v2</a> 078 * </ul> 079 */ 080@SuppressWarnings({ 081 "java:S116", // Field name uses trailing underscore (default_) to avoid Java keyword conflict 082 "java:S1192" // Duplicated literals (argument/property names) read more clearly inline than as constants 083}) 084public class HeaderInfo extends SwaggerElement { 085 086 private static final String[] VALID_TYPES = { "string", "number", "integer", "boolean", "array" }; 087 private static final String[] VALID_COLLECTION_FORMATS = { "csv", "ssv", "tsv", "pipes", "multi" }; 088 089 private String description; 090 private String type; 091 private String format; 092 private String collectionFormat; 093 private String pattern; 094 private String ref; 095 private Number maximum; 096 private Number minimum; 097 private Number multipleOf; 098 private Integer maxLength; 099 private Integer minLength; 100 private Integer maxItems; 101 private Integer minItems; 102 private Boolean exclusiveMaximum; 103 private Boolean exclusiveMinimum; 104 private Boolean uniqueItems; 105 private Items items; 106 private Object default_; 107 private final Set<Object> enum_ = st(); 108 private Object example; 109 110 /** 111 * Default constructor. 112 */ 113 public HeaderInfo() {} 114 115 /** 116 * Copy constructor. 117 * 118 * @param copyFrom The object to copy. 119 */ 120 public HeaderInfo(HeaderInfo copyFrom) { 121 super(copyFrom); 122 123 this.collectionFormat = copyFrom.collectionFormat; 124 this.default_ = copyFrom.default_; 125 this.description = copyFrom.description; 126 this.enum_.addAll(copyOf(copyFrom.enum_)); 127 this.example = copyFrom.example; 128 this.exclusiveMaximum = copyFrom.exclusiveMaximum; 129 this.exclusiveMinimum = copyFrom.exclusiveMinimum; 130 this.format = copyFrom.format; 131 this.items = copyOf(copyFrom.items); 132 this.maximum = copyFrom.maximum; 133 this.maxItems = copyFrom.maxItems; 134 this.maxLength = copyFrom.maxLength; 135 this.minimum = copyFrom.minimum; 136 this.minItems = copyFrom.minItems; 137 this.minLength = copyFrom.minLength; 138 this.multipleOf = copyFrom.multipleOf; 139 this.pattern = copyFrom.pattern; 140 this.ref = copyFrom.ref; 141 this.type = copyFrom.type; 142 this.uniqueItems = copyFrom.uniqueItems; 143 } 144 145 /** 146 * Bean property fluent setter: <property>enum</property>. 147 * 148 * @param value 149 * The new value for this property. 150 * <br>Strings can be JSON arrays. 151 * @return This object. 152 */ 153 public HeaderInfo addEnum(Object...value) { 154 addAllNn(enum_, value); 155 return this; 156 } 157 158 /** 159 * Make a deep copy of this object. 160 * 161 * @return A deep copy of this object. 162 */ 163 public HeaderInfo copy() { 164 return new HeaderInfo(this); 165 } 166 167 @Override /* Overridden from SwaggerElement */ 168 public <T> T get(String property, Class<T> type) { 169 reqnn("property", property); 170 return switch (property) { 171 case "collectionFormat" -> toType(getCollectionFormat(), type); 172 case "default" -> toType(getDefault(), type); 173 case "description" -> toType(getDescription(), type); 174 case "enum" -> toType(getEnum(), type); 175 case "example" -> toType(getExample(), type); 176 case "exclusiveMaximum" -> toType(getExclusiveMaximum(), type); 177 case "exclusiveMinimum" -> toType(getExclusiveMinimum(), type); 178 case "format" -> toType(getFormat(), type); 179 case "items" -> toType(getItems(), type); 180 case "maximum" -> toType(getMaximum(), type); 181 case "maxItems" -> toType(getMaxItems(), type); 182 case "maxLength" -> toType(getMaxLength(), type); 183 case "minimum" -> toType(getMinimum(), type); 184 case "minItems" -> toType(getMinItems(), type); 185 case "minLength" -> toType(getMinLength(), type); 186 case "multipleOf" -> toType(getMultipleOf(), type); 187 case "pattern" -> toType(getPattern(), type); 188 case "$ref" -> toType(getRef(), type); 189 case "type" -> toType(getType(), type); 190 case "uniqueItems" -> toType(getUniqueItems(), type); 191 default -> super.get(property, type); 192 }; 193 } 194 195 /** 196 * Bean property getter: <property>collectionFormat</property>. 197 * 198 * <p> 199 * Determines the format of the array if type array is used. 200 * 201 * @return The property value, or <jk>null</jk> if it is not set. 202 */ 203 public String getCollectionFormat() { return collectionFormat; } 204 205 /** 206 * Bean property getter: <property>default</property>. 207 * 208 * <p> 209 * Declares the value of the header that the server will use if none is provided. 210 * 211 * <h5 class='section'>Notes:</h5><ul> 212 * <li class='note'> 213 * <js>"default"</js> has no meaning for required items. 214 * <li class='note'> 215 * Unlike JSON Schema this value MUST conform to the defined <c>type</c> for the header. 216 * </ul> 217 * 218 * @return The property value, or <jk>null</jk> if it is not set. 219 */ 220 public Object getDefault() { return default_; } 221 222 /** 223 * Bean property getter: <property>description</property>. 224 * 225 * <p> 226 * A short description of the header. 227 * 228 * @return The property value, or <jk>null</jk> if it is not set. 229 */ 230 public String getDescription() { return description; } 231 232 /** 233 * Bean property getter: <property>enum</property>. 234 * 235 * @return The property value, or <jk>null</jk> if it is not set. 236 */ 237 public Set<Object> getEnum() { return nie(enum_); } 238 239 /** 240 * Bean property getter: <property>example</property>. 241 * 242 * @return The property value, or <jk>null</jk> if it is not set. 243 */ 244 public Object getExample() { return example; } 245 246 /** 247 * Bean property getter: <property>exclusiveMaximum</property>. 248 * 249 * @return The property value, or <jk>null</jk> if it is not set. 250 */ 251 public Boolean getExclusiveMaximum() { return exclusiveMaximum; } 252 253 /** 254 * Bean property getter: <property>exclusiveMinimum</property>. 255 * 256 * @return The property value, or <jk>null</jk> if it is not set. 257 */ 258 public Boolean getExclusiveMinimum() { return exclusiveMinimum; } 259 260 /** 261 * Bean property getter: <property>format</property>. 262 * 263 * <p> 264 * The extending format for the previously mentioned <c>type</c>. 265 * 266 * @return The property value, or <jk>null</jk> if it is not set. 267 */ 268 public String getFormat() { return format; } 269 270 /** 271 * Bean property getter: <property>items</property>. 272 * 273 * <p> 274 * Describes the type of items in the array. 275 * 276 * @return The property value, or <jk>null</jk> if it is not set. 277 */ 278 public Items getItems() { return items; } 279 280 /** 281 * Bean property getter: <property>maximum</property>. 282 * 283 * @return The property value, or <jk>null</jk> if it is not set. 284 */ 285 public Number getMaximum() { return maximum; } 286 287 /** 288 * Bean property getter: <property>maxItems</property>. 289 * 290 * @return The property value, or <jk>null</jk> if it is not set. 291 */ 292 public Integer getMaxItems() { return maxItems; } 293 294 /** 295 * Bean property getter: <property>maxLength</property>. 296 * 297 * @return The property value, or <jk>null</jk> if it is not set. 298 */ 299 public Integer getMaxLength() { return maxLength; } 300 301 /** 302 * Bean property getter: <property>minimum</property>. 303 * 304 * @return The property value, or <jk>null</jk> if it is not set. 305 */ 306 public Number getMinimum() { return minimum; } 307 308 /** 309 * Bean property getter: <property>minItems</property>. 310 * 311 * @return The property value, or <jk>null</jk> if it is not set. 312 */ 313 public Integer getMinItems() { return minItems; } 314 315 /** 316 * Bean property getter: <property>minLength</property>. 317 * 318 * @return The property value, or <jk>null</jk> if it is not set. 319 */ 320 public Integer getMinLength() { return minLength; } 321 322 /** 323 * Bean property getter: <property>multipleOf</property>. 324 * 325 * @return The property value, or <jk>null</jk> if it is not set. 326 */ 327 public Number getMultipleOf() { return multipleOf; } 328 329 /** 330 * Bean property getter: <property>pattern</property>. 331 * 332 * @return The property value, or <jk>null</jk> if it is not set. 333 */ 334 public String getPattern() { return pattern; } 335 336 /** 337 * Bean property getter: <property>$ref</property>. 338 * 339 * @return The property value, or <jk>null</jk> if it is not set. 340 */ 341 @BeanProp("$ref") 342 public String getRef() { return ref; } 343 344 /** 345 * Bean property getter: <property>type</property>. 346 * 347 * <p> 348 * The type of the object. 349 * 350 * @return The property value, or <jk>null</jk> if it is not set. 351 */ 352 public String getType() { return type; } 353 354 /** 355 * Bean property getter: <property>uniqueItems</property>. 356 * 357 * @return The property value, or <jk>null</jk> if it is not set. 358 */ 359 public Boolean getUniqueItems() { return uniqueItems; } 360 361 @Override /* Overridden from SwaggerElement */ 362 public Set<String> keySet() { 363 // @formatter:off 364 var s = stb(String.class) 365 .addIf(nn(ref), "$ref") 366 .addIf(nn(collectionFormat), "collectionFormat") 367 .addIf(nn(default_), "default") 368 .addIf(nn(description), "description") 369 .addIf(ine(enum_), "enum") 370 .addIf(nn(example), "example") 371 .addIf(nn(exclusiveMaximum), "exclusiveMaximum") 372 .addIf(nn(exclusiveMinimum), "exclusiveMinimum") 373 .addIf(nn(format), "format") 374 .addIf(nn(items), "items") 375 .addIf(nn(maxItems), "maxItems") 376 .addIf(nn(maxLength), "maxLength") 377 .addIf(nn(maximum), "maximum") 378 .addIf(nn(minItems), "minItems") 379 .addIf(nn(minLength), "minLength") 380 .addIf(nn(minimum), "minimum") 381 .addIf(nn(multipleOf), "multipleOf") 382 .addIf(nn(pattern), "pattern") 383 .addIf(nn(type), "type") 384 .addIf(nn(uniqueItems), "uniqueItems") 385 .build(); 386 // @formatter:on 387 return new MultiSet<>(s, super.keySet()); 388 } 389 390 /** 391 * Resolves any <js>"$ref"</js> attributes in this element. 392 * 393 * @param swagger The swagger document containing the definitions. 394 * @param refStack Keeps track of previously-visited references so that we don't cause recursive loops. 395 * @param maxDepth 396 * The maximum depth to resolve references. 397 * <br>After that level is reached, <c>$ref</c> references will be left alone. 398 * <br>Useful if you have very complex models and you don't want your swagger page to be overly-complex. 399 * @return 400 * This object with references resolved. 401 * <br>May or may not be the same object. 402 */ 403 public HeaderInfo resolveRefs(Swagger swagger, Deque<String> refStack, int maxDepth) { 404 405 if (nn(ref)) { 406 if (refStack.contains(ref) || refStack.size() >= maxDepth) 407 return this; 408 refStack.addLast(ref); 409 var r = swagger.findRef(ref, HeaderInfo.class).resolveRefs(swagger, refStack, maxDepth); 410 refStack.removeLast(); 411 return r; 412 } 413 414 if (nn(items)) 415 items = items.resolveRefs(swagger, refStack, maxDepth); 416 417 return this; 418 } 419 420 @Override /* Overridden from SwaggerElement */ 421 public HeaderInfo set(String property, Object value) { 422 reqnn("property", property); 423 return switch (property) { 424 case "collectionFormat" -> setCollectionFormat(s(value)); 425 case "default" -> setDefault(value); 426 case "description" -> setDescription(s(value)); 427 case "enum" -> setEnum(stb(Object.class).sparse().addAny(value).build()); 428 case "example" -> setExample(value); 429 case "exclusiveMaximum" -> setExclusiveMaximum(toBoolean(value)); 430 case "exclusiveMinimum" -> setExclusiveMinimum(toBoolean(value)); 431 case "format" -> setFormat(s(value)); 432 case "items" -> setItems(toType(value, Items.class)); 433 case "maximum" -> setMaximum(toNumber(value)); 434 case "maxItems" -> setMaxItems(toInteger(value)); 435 case "maxLength" -> setMaxLength(toInteger(value)); 436 case "minimum" -> setMinimum(toNumber(value)); 437 case "minItems" -> setMinItems(toInteger(value)); 438 case "minLength" -> setMinLength(toInteger(value)); 439 case "multipleOf" -> setMultipleOf(toNumber(value)); 440 case "pattern" -> setPattern(s(value)); 441 case "$ref" -> setRef(s(value)); 442 case "type" -> setType(s(value)); 443 case "uniqueItems" -> setUniqueItems(toBoolean(value)); 444 default -> { 445 super.set(property, value); 446 yield this; 447 } 448 }; 449 } 450 451 /** 452 * Bean property setter: <property>collectionFormat</property>. 453 * 454 * <p> 455 * Determines the format of the array if type array is used. 456 * 457 * @param value 458 * The new value for this property. 459 * <br>Valid values: 460 * <ul> 461 * <li><js>"csv"</js> (default) - comma separated values <c>foo,bar</c>. 462 * <li><js>"ssv"</js> - space separated values <c>foo bar</c>. 463 * <li><js>"tsv"</js> - tab separated values <c>foo\tbar</c>. 464 * <li><js>"pipes"</js> - pipe separated values <c>foo|bar</c>. 465 * </ul> 466 * <br>Can be <jk>null</jk> to unset the property. 467 * @return This object. 468 */ 469 public HeaderInfo setCollectionFormat(String value) { 470 if (isStrict() && ! contains(value, VALID_COLLECTION_FORMATS)) 471 throw rex("Invalid value passed in to setCollectionFormat(String). Value='%s', valid values=%s", value, Json5.of(VALID_COLLECTION_FORMATS)); 472 collectionFormat = value; 473 return this; 474 } 475 476 /** 477 * Bean property setter: <property>default</property>. 478 * 479 * <p> 480 * Declares the value of the header that the server will use if none is provided. 481 * 482 * <h5 class='section'>Notes:</h5><ul> 483 * <li class='note'> 484 * <js>"default"</js> has no meaning for required items. 485 * <li class='note'> 486 * Unlike JSON Schema this value MUST conform to the defined <c>type</c> for the header. 487 * </ul> 488 * 489 * @param value 490 * The new value for this property. 491 * <br>Can be <jk>null</jk> to unset the property. 492 * @return This object. 493 */ 494 public HeaderInfo setDefault(Object value) { 495 default_ = value; 496 return this; 497 } 498 499 /** 500 * Bean property setter: <property>description</property>. 501 * 502 * <p> 503 * A short description of the header. 504 * 505 * @param value 506 * The new value for this property. 507 * <br>Can be <jk>null</jk> to unset the property. 508 * @return This object. 509 */ 510 public HeaderInfo setDescription(String value) { 511 description = value; 512 return this; 513 } 514 515 /** 516 * Bean property setter: <property>enum</property>. 517 * 518 * @param value 519 * The new value for this property. 520 * <br>Can be <jk>null</jk> to unset the property. 521 * @return This object. 522 */ 523 public HeaderInfo setEnum(Collection<Object> value) { 524 enum_.clear(); 525 if (nn(value)) 526 enum_.addAll(value); 527 return this; 528 } 529 530 /** 531 * Bean property setter: <property>enum</property>. 532 * 533 * @param value 534 * The new value for this property. 535 * <br>Can be <jk>null</jk> to unset the property. 536 * @return This object. 537 */ 538 public HeaderInfo setEnum(Object...value) { 539 return setEnum(l(value)); 540 } 541 542 /** 543 * Bean property setter: <property>example</property>. 544 * 545 * @param value 546 * The new value for this property. 547 * <br>Can be <jk>null</jk> to unset the property. 548 * @return This object. 549 */ 550 public HeaderInfo setExample(Object value) { 551 example = value; 552 return this; 553 } 554 555 /** 556 * Bean property setter: <property>exclusiveMaximum</property>. 557 * 558 * @param value 559 * The new value for this property. 560 * <br>Can be <jk>null</jk> to unset the property. 561 * @return This object. 562 */ 563 public HeaderInfo setExclusiveMaximum(Boolean value) { 564 exclusiveMaximum = value; 565 return this; 566 } 567 568 /** 569 * Bean property setter: <property>exclusiveMinimum</property>. 570 * 571 * @param value 572 * The new value for this property. 573 * <br>Can be <jk>null</jk> to unset the property. 574 * @return This object. 575 */ 576 public HeaderInfo setExclusiveMinimum(Boolean value) { 577 exclusiveMinimum = value; 578 return this; 579 } 580 581 /** 582 * Bean property setter: <property>format</property>. 583 * 584 * <p> 585 * The extending format for the previously mentioned <c>type</c>. 586 * 587 * @param value 588 * The new value for this property. 589 * <br>Can be <jk>null</jk> to unset the property. 590 * @return This object. 591 */ 592 public HeaderInfo setFormat(String value) { 593 format = value; 594 return this; 595 } 596 597 /** 598 * Bean property setter: <property>items</property>. 599 * 600 * <p> 601 * Describes the type of items in the array. 602 * 603 * @param value 604 * The new value for this property. 605 * <br>Property value is required if <c>type</c> is <js>"array"</js>. 606 * <br>Can be <jk>null</jk> to unset the property. 607 * @return This object. 608 */ 609 public HeaderInfo setItems(Items value) { 610 items = value; 611 return this; 612 } 613 614 /** 615 * Bean property setter: <property>maximum</property>. 616 * 617 * @param value 618 * The new value for this property. 619 * <br>Can be <jk>null</jk> to unset the property. 620 * @return This object. 621 */ 622 public HeaderInfo setMaximum(Number value) { 623 maximum = value; 624 return this; 625 } 626 627 /** 628 * Bean property setter: <property>maxItems</property>. 629 * 630 * @param value 631 * The new value for this property. 632 * <br>Can be <jk>null</jk> to unset the property. 633 * @return This object. 634 */ 635 public HeaderInfo setMaxItems(Integer value) { 636 maxItems = value; 637 return this; 638 } 639 640 /** 641 * Bean property setter: <property>maxLength</property>. 642 * 643 * @param value 644 * The new value for this property. 645 * <br>Can be <jk>null</jk> to unset the property. 646 * @return This object. 647 */ 648 public HeaderInfo setMaxLength(Integer value) { 649 maxLength = value; 650 return this; 651 } 652 653 /** 654 * Bean property setter: <property>minimum</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. 660 */ 661 public HeaderInfo setMinimum(Number value) { 662 minimum = value; 663 return this; 664 } 665 666 /** 667 * Bean property setter: <property>minItems</property>. 668 * 669 * @param value 670 * The new value for this property. 671 * <br>Can be <jk>null</jk> to unset the property. 672 * @return This object. 673 */ 674 public HeaderInfo setMinItems(Integer value) { 675 minItems = value; 676 return this; 677 } 678 679 /** 680 * Bean property setter: <property>minLength</property>. 681 * 682 * @param value 683 * The new value for this property. 684 * <br>Can be <jk>null</jk> to unset the property. 685 * @return This object. 686 */ 687 public HeaderInfo setMinLength(Integer value) { 688 minLength = value; 689 return this; 690 } 691 692 /** 693 * Bean property setter: <property>multipleOf</property>. 694 * 695 * @param value 696 * The new value for this property. 697 * <br>Can be <jk>null</jk> to unset the property. 698 * @return This object. 699 */ 700 public HeaderInfo setMultipleOf(Number value) { 701 multipleOf = value; 702 return this; 703 } 704 705 /** 706 * Bean property setter: <property>pattern</property>. 707 * 708 * @param value 709 * The new value for this property. 710 * <br>This string SHOULD be a valid regular expression. 711 * <br>Can be <jk>null</jk> to unset the property. 712 * @return This object. 713 */ 714 public HeaderInfo setPattern(String value) { 715 pattern = value; 716 return this; 717 } 718 719 /** 720 * Bean property setter: <property>$ref</property>. 721 * 722 * @param value 723 * The new value for this property. 724 * <br>Can be <jk>null</jk> to unset the property. 725 * @return This object. 726 */ 727 @BeanProp("$ref") 728 public HeaderInfo setRef(String value) { 729 ref = value; 730 return this; 731 } 732 733 /** 734 * Bean property setter: <property>type</property>. 735 * 736 * <p> 737 * The type of the object. 738 * 739 * @param value 740 * The new value for this property. 741 * <br>Property value is required. 742 * <br>Can be <jk>null</jk> to unset the property. 743 * <br>Valid values: 744 * <ul> 745 * <li><js>"string"</js> 746 * <li><js>"number"</js> 747 * <li><js>"integer"</js> 748 * <li><js>"boolean"</js> 749 * <li><js>"array"</js> 750 * </ul> 751 * @return This object. 752 */ 753 public HeaderInfo setType(String value) { 754 if (isStrict() && ! contains(value, VALID_TYPES)) 755 throw rex("Invalid value passed in to setType(String). Value='%s', valid values=%s", value, Json5.of(VALID_TYPES)); 756 type = value; 757 return this; 758 } 759 760 /** 761 * Bean property setter: <property>uniqueItems</property>. 762 * 763 * @param value 764 * The new value for this property. 765 * <br>Can be <jk>null</jk> to unset the property. 766 * @return This object. 767 */ 768 public HeaderInfo setUniqueItems(Boolean value) { 769 uniqueItems = value; 770 return this; 771 } 772 773 @Override /* Overridden from SwaggerElement */ 774 public HeaderInfo strict() { 775 super.strict(); 776 return this; 777 } 778}