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