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.http.annotation; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.lang.annotation.*; 019import java.util.*; 020 021import org.apache.juneau.jsonschema.annotation.Items; 022import org.apache.juneau.*; 023import org.apache.juneau.annotation.*; 024import org.apache.juneau.collections.*; 025import org.apache.juneau.httppart.*; 026import org.apache.juneau.json.*; 027import org.apache.juneau.jsonschema.*; 028import org.apache.juneau.oapi.*; 029 030/** 031 * REST request path annotation. 032 * 033 * <p> 034 * Identifies a POJO to be used as a path entry on an HTTP request. 035 * 036 * <p> 037 * Can be used in the following locations: 038 * <ul> 039 * <li>Arguments and argument-types of server-side <ja>@RestMethod</ja>-annotated methods. 040 * <li>Arguments and argument-types of client-side <ja>@RemoteResource</ja>-annotated interfaces. 041 * <li>Methods and return types of server-side and client-side <ja>@Request</ja>-annotated interfaces. 042 * </ul> 043 * 044 * <h5 class='topic'>Arguments and argument-types of server-side @RestMethod-annotated methods</h5> 045 * 046 * Annotation that can be applied to a parameter of a <ja>@RestMethod</ja>-annotated method to identify it as a variable 047 * in a URL path pattern. 048 * 049 * <h5 class='section'>Example:</h5> 050 * <p class='bcode w800'> 051 * <ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/myurl/{foo}/{bar}/{baz}/*"</js>) 052 * <jk>public void</jk> doGet( 053 * <ja>@Path</ja>(<js>"foo"</js>) String foo, 054 * <ja>@Path</ja>(<js>"bar"</js>) <jk>int</jk> bar, 055 * <ja>@Path</ja>(<js>"baz"</js>) UUID baz, 056 * <ja>@Path</ja>(<js>"/*"</js>) String remainder, 057 * ) {...} 058 * </p> 059 * 060 * <p> 061 * The special name <js>"/*"</js> is used to retrieve the path remainder after the path match (i.e. the part that matches <js>"/*"</js>). 062 * 063 * <ul class='seealso'> 064 * <li class='link'>{@doc RestPathAnnotation} 065 * <li class='link'>{@doc RestSwagger} 066 * <li class='extlink'>{@doc ExtSwaggerParameterObject} 067 * </ul> 068 * 069 * <h5 class='topic'>Arguments and argument-types of client-side @RemoteResource-annotated interfaces</h5> 070 * 071 * Annotation applied to Java method arguments of interface proxies to denote that they are path variables on the request. 072 * 073 * <ul class='seealso'> 074 * <li class='link'>{@doc RestcPath} 075 * </ul> 076 * 077 * <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5> 078 * 079 * <ul class='seealso'> 080 * <li class='link'>{@doc RestRequestAnnotation} 081 * <li class='link'>{@doc RestcRequest} 082 * </ul> 083 */ 084@Documented 085@Target({PARAMETER,FIELD,METHOD,TYPE}) 086@Retention(RUNTIME) 087@Inherited 088public @interface Path { 089 090 /** 091 * Specifies the {@link HttpPartSerializer} class used for serializing values to strings. 092 * 093 * <p> 094 * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}. 095 */ 096 Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Null.class; 097 098 /** 099 * Specifies the {@link HttpPartParser} class used for parsing strings to values. 100 * 101 * <p> 102 * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}. 103 */ 104 Class<? extends HttpPartParser> parser() default HttpPartParser.Null.class; 105 106 //================================================================================================================= 107 // Attributes common to all Swagger Parameter objects 108 //================================================================================================================= 109 110 /** 111 * URL path variable name. 112 * 113 * <p> 114 * The path remainder after the path match can be referenced using the name <js>"/*"</js>. 115 * <br>The non-URL-decoded path remainder after the path match can be referenced using the name <js>"/**"</js>. 116 * 117 * <p> 118 * The value should be either a valid path parameter name, or <js>"*"</js> to represent multiple name/value pairs 119 * 120 * <p> 121 * A blank value (the default) has the following behavior: 122 * <ul class='spaced-list'> 123 * <li> 124 * If the data type is <c>NameValuePairs</c>, <c>Map</c>, or a bean, 125 * then it's the equivalent to <js>"*"</js> which will cause the value to be treated as name/value pairs. 126 * 127 * <h5 class='figure'>Examples:</h5> 128 * <p class='bcode w800'> 129 * <jc>// When used on a REST method</jc> 130 * <ja>@RestMethod</ja>(path=<js>"/addPet"</js>) 131 * <jk>public void</jk> addPet(<ja>@Path</ja> OMap allPathParameters) {...} 132 * </p> 133 * <p class='bcode w800'> 134 * <jc>// When used on a remote method parameter</jc> 135 * <ja>@RemoteResource</ja>(path=<js>"/myproxy"</js>) 136 * <jk>public interface</jk> MyProxy { 137 * 138 * <jc>// Equivalent to @Path("*")</jc> 139 * <ja>@RemoteMethod</ja>(path=<js>"/mymethod/{foo}/{bar}"</js>) 140 * String myProxyMethod1(<ja>@Path</ja> Map<String,Object> allPathParameters); 141 * } 142 * </p> 143 * <p class='bcode w800'> 144 * <jc>// When used on a request bean method</jc> 145 * <jk>public interface</jk> MyRequest { 146 * 147 * <jc>// Equivalent to @Path("*")</jc> 148 * <ja>@Path</ja> 149 * Map<String,Object> getPathVars(); 150 * } 151 * </p> 152 * </li> 153 * <li> 154 * If used on a request bean method, uses the bean property name. 155 * 156 * <h5 class='figure'>Example:</h5> 157 * <p class='bcode w800'> 158 * <jk>public interface</jk> MyRequest { 159 * 160 * <jc>// Equivalent to @Path("foo")</jc> 161 * <ja>@Path</ja> 162 * String getFoo(); 163 * } 164 * </ul> 165 * 166 * <p> 167 * The name field MUST correspond to the associated {@doc ExtSwaggerPathsPath path} segment from the path field in the {@doc ExtSwaggerPathsObject Paths Object}. 168 * See {@doc ExtSwaggerPathTemplating Path Templating} for further information. 169 * 170 * <ul class='notes'> 171 * <li> 172 * The format is plain-text. 173 * </ul> 174 */ 175 String name() default ""; 176 177 /** 178 * Synonym for {@link #name()}. 179 */ 180 String n() default ""; 181 182 /** 183 * A synonym for {@link #name()}. 184 * 185 * <p> 186 * Allows you to use shortened notation if you're only specifying the name. 187 * 188 * <p> 189 * The following are completely equivalent ways of defining a path entry: 190 * <p class='bcode w800'> 191 * <ja>@RestMethod</ja>( 192 * name=<js>"GET"</js>, 193 * path=<js>"/pet/{petId}"</js> 194 * ) 195 * <jk>public</jk> Pet getPet(<ja>@Path</ja>(name=<js>"petId"</js>) <jk>long</jk> petId) { ... } 196 * </p> 197 * <p class='bcode w800'> 198 * <ja>@RestMethod</ja>( 199 * name=<js>"GET"</js>, 200 * path=<js>"/pet/{petId}"</js> 201 * ) 202 * <jk>public</jk> Pet getPet(<ja>@Path</ja>(<js>"petId"</js>) <jk>long</jk> petId) { ... } 203 * </p> 204 */ 205 String value() default ""; 206 207 /** 208 * <mk>description</mk> field of the {@doc ExtSwaggerParameterObject}. 209 * 210 * <p> 211 * A brief description of the parameter. This could contain examples of use. 212 * 213 * <h5 class='section'>Used for:</h5> 214 * <ul class='spaced-list'> 215 * <li> 216 * Server-side generated Swagger documentation. 217 * </ul> 218 * 219 * <ul class='notes'> 220 * <li> 221 * The format is plain text. 222 * <br>Multiple lines are concatenated with newlines. 223 * <li> 224 * Supports {@doc RestSvlVariables} 225 * (e.g. <js>"$L{my.localized.variable}"</js>). 226 * </ul> 227 */ 228 String[] description() default {}; 229 230 /** 231 * Synonym for {@link #description()}. 232 */ 233 String[] d() default {}; 234 235 /** 236 * <mk>required</mk> field of the {@doc ExtSwaggerParameterObject}. 237 * 238 * <p> 239 * Determines whether the parameter is mandatory. 240 * 241 * <p> 242 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 243 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 244 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 245 * 246 * <p> 247 * A path can be marked as not-required when the path variable is resolved by a parent resource like so: 248 * 249 * <p class='bcode w800'> 250 * <ja>@Rest</ja>(path=<js>"/parent/{p1}"</js>,children=Child.<jk>class</jk>) 251 * <jk>public class</jk> Parent { 252 * ... 253 * } 254 * 255 * <ja>@Rest</ja>(path="/child") 256 * <jk>public class</jk> Child { 257 * 258 * <ja>@RestMethod</ja>(path="/") 259 * <jk>public</jk> String doGet(<ja>@Path</ja>(name=<js>"p1"</js>,required=<jk>false</jk>) String p1) { 260 * <jc>// p1 will be null when accessed via "/child"</jc> 261 * <jc>// p1 will be non-null when accessed via "/parent/p1/child".</jc> 262 * } 263 * ... 264 * } 265 * </p> 266 * 267 * <p> 268 * This allows the child resource to be mapped to multiple parents that may resolve various different path variables. 269 * 270 * <h5 class='section'>Used for:</h5> 271 * <ul class='spaced-list'> 272 * <li> 273 * Server-side schema-based parsing validation. 274 * <li> 275 * Server-side generated Swagger documentation. 276 * <li> 277 * Client-side schema-based serializing validation. 278 * </ul> 279 */ 280 boolean required() default true; 281 282 /** 283 * Synonym for {@link #required()}. 284 */ 285 boolean r() default true; 286 287 //================================================================================================================= 288 // Attributes specific to parameters other than body 289 //================================================================================================================= 290 291 /** 292 * <mk>type</mk> field of the {@doc ExtSwaggerParameterObject}. 293 * 294 * <p> 295 * The type of the parameter. 296 * 297 * <p> 298 * The possible values are: 299 * <ul class='spaced-list'> 300 * <li> 301 * <js>"string"</js> 302 * <br>Parameter must be a string or a POJO convertible from a string. 303 * <li> 304 * <js>"number"</js> 305 * <br>Parameter must be a number primitive or number object. 306 * <br>If parameter is <c>Object</c>, creates either a <c>Float</c> or <c>Double</c> depending on the size of the number. 307 * <li> 308 * <js>"integer"</js> 309 * <br>Parameter must be a integer/long primitive or integer/long object. 310 * <br>If parameter is <c>Object</c>, creates either a <c>Short</c>, <c>Integer</c>, or <c>Long</c> depending on the size of the number. 311 * <li> 312 * <js>"boolean"</js> 313 * <br>Parameter must be a boolean primitive or object. 314 * <li> 315 * <js>"array"</js> 316 * <br>Parameter must be an array or collection. 317 * <br>Elements must be strings or POJOs convertible from strings. 318 * <br>If parameter is <c>Object</c>, creates an {@link OList}. 319 * <li> 320 * <js>"object"</js> 321 * <br>Parameter must be a map or bean. 322 * <br>If parameter is <c>Object</c>, creates an {@link OMap}. 323 * <br>Note that this is an extension of the OpenAPI schema as Juneau allows for arbitrarily-complex POJOs to be serialized as HTTP parts. 324 * <li> 325 * <js>"file"</js> 326 * <br>This type is currently not supported. 327 * </ul> 328 * 329 * <p> 330 * Static strings are defined in {@link ParameterType}. 331 * 332 * <h5 class='section'>Used for:</h5> 333 * <ul class='spaced-list'> 334 * <li> 335 * Server-side schema-based parsing. 336 * <li> 337 * Server-side generated Swagger documentation. 338 * <li> 339 * Client-side schema-based serializing. 340 * </ul> 341 * 342 * <ul class='seealso'> 343 * <li class='extlink'>{@doc ExtSwaggerDataTypes} 344 * </ul> 345 */ 346 String type() default ""; 347 348 /** 349 * Synonym for {@link #type()}. 350 */ 351 String t() default ""; 352 353 /** 354 * <mk>format</mk> field of the {@doc ExtSwaggerParameterObject}. 355 * 356 * <p> 357 * The extending format for the previously mentioned {@doc ExtSwaggerParameterTypes parameter type}. 358 * 359 * <p> 360 * The possible values are: 361 * <ul class='spaced-list'> 362 * <li> 363 * <js>"int32"</js> - Signed 32 bits. 364 * <br>Only valid with type <js>"integer"</js>. 365 * <li> 366 * <js>"int64"</js> - Signed 64 bits. 367 * <br>Only valid with type <js>"integer"</js>. 368 * <li> 369 * <js>"float"</js> - 32-bit floating point number. 370 * <br>Only valid with type <js>"number"</js>. 371 * <li> 372 * <js>"double"</js> - 64-bit floating point number. 373 * <br>Only valid with type <js>"number"</js>. 374 * <li> 375 * <js>"byte"</js> - BASE-64 encoded characters. 376 * <br>Only valid with type <js>"string"</js>. 377 * <br>Parameters of type POJO convertible from string are converted after the string has been decoded. 378 * <li> 379 * <js>"binary"</js> - Hexadecimal encoded octets (e.g. <js>"00FF"</js>). 380 * <br>Only valid with type <js>"string"</js>. 381 * <br>Parameters of type POJO convertible from string are converted after the string has been decoded. 382 * <li> 383 * <js>"date"</js> - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 full-date</a>. 384 * <br>Only valid with type <js>"string"</js>. 385 * <li> 386 * <js>"date-time"</js> - An <a href='http://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14'>RFC3339 date-time</a>. 387 * <br>Only valid with type <js>"string"</js>. 388 * <li> 389 * <js>"password"</js> - Used to hint UIs the input needs to be obscured. 390 * <br>This format does not affect the serialization or parsing of the parameter. 391 * <li> 392 * <js>"uon"</js> - UON notation (e.g. <js>"(foo=bar,baz=@(qux,123))"</js>). 393 * <br>Only valid with type <js>"object"</js>. 394 * <br>If not specified, then the input is interpreted as plain-text and is converted to a POJO directly. 395 * </ul> 396 * 397 * <p> 398 * Static strings are defined in {@link FormatType}. 399 * 400 * <h5 class='section'>Used for:</h5> 401 * <ul class='spaced-list'> 402 * <li> 403 * Server-side schema-based parsing. 404 * <li> 405 * Server-side generated Swagger documentation. 406 * <li> 407 * Client-side schema-based serializing. 408 * </ul> 409 * 410 * <ul class='seealso'> 411 * <li class='extlink'>{@doc ExtSwaggerDataTypeFormats} 412 * </ul> 413 */ 414 String format() default ""; 415 416 /** 417 * Synonym for {@link #format()}. 418 */ 419 String f() default ""; 420 421 /** 422 * <mk>allowEmptyValue</mk> field of the {@doc ExtSwaggerParameterObject}. 423 * 424 * <p> 425 * Sets the ability to pass empty-valued path parameter values. 426 * 427 * <h5 class='section'>Used for:</h5> 428 * <ul class='spaced-list'> 429 * <li> 430 * Server-side schema-based parsing validation. 431 * <li> 432 * Server-side generated Swagger documentation. 433 * <li> 434 * Client-side schema-based serializing validation. 435 * </ul> 436 * 437 * <p> 438 * <b>Note:</b> This is technically only valid for either query or formData parameters, but support is provided anyway for backwards compatability. 439 */ 440 boolean allowEmptyValue() default false; 441 442 /** 443 * Synonym for {@link #allowEmptyValue()}. 444 */ 445 boolean aev() default false; 446 447 /** 448 * <mk>items</mk> field of the {@doc ExtSwaggerParameterObject}. 449 * 450 * <p> 451 * Describes the type of items in the array. 452 * <p> 453 * Required if <c>type</c> is <js>"array"</js>. 454 * <br>Can only be used if <c>type</c> is <js>"array"</js>. 455 * 456 * <h5 class='section'>Used for:</h5> 457 * <ul class='spaced-list'> 458 * <li> 459 * Server-side schema-based parsing and parsing validation. 460 * <li> 461 * Server-side generated Swagger documentation. 462 * <li> 463 * Client-side schema-based serializing and serializing validation. 464 * </ul> 465 */ 466 Items items() default @Items; 467 468 /** 469 * <mk>collectionFormat</mk> field of the {@doc ExtSwaggerParameterObject}. 470 * 471 * <p> 472 * Determines the format of the array if <c>type</c> <js>"array"</js> is used. 473 * <br>Can only be used if <c>type</c> is <js>"array"</js>. 474 * 475 * <br>Possible values are: 476 * <ul class='spaced-list'> 477 * <li> 478 * <js>"csv"</js> (default) - Comma-separated values (e.g. <js>"foo,bar"</js>). 479 * <li> 480 * <js>"ssv"</js> - Space-separated values (e.g. <js>"foo bar"</js>). 481 * <li> 482 * <js>"tsv"</js> - Tab-separated values (e.g. <js>"foo\tbar"</js>). 483 * <li> 484 * <js>"pipes</js> - Pipe-separated values (e.g. <js>"foo|bar"</js>). 485 * <li> 486 * <js>"uon"</js> - UON notation (e.g. <js>"@(foo,bar)"</js>). 487 * <li> 488 * </ul> 489 * 490 * <p> 491 * Static strings are defined in {@link CollectionFormatType}. 492 * 493 * <p> 494 * Note that for collections/arrays parameters with POJO element types, the input is broken into a string array before being converted into POJO elements. 495 * 496 * <h5 class='section'>Used for:</h5> 497 * <ul class='spaced-list'> 498 * <li> 499 * Server-side schema-based parsing. 500 * <li> 501 * Server-side generated Swagger documentation. 502 * <li> 503 * Client-side schema-based serializing. 504 * </ul> 505 */ 506 String collectionFormat() default ""; 507 508 /** 509 * Synonym for {@link #collectionFormat()}. 510 */ 511 String cf() default ""; 512 513 /** 514 * <mk>maximum</mk> field of the {@doc ExtSwaggerParameterObject}. 515 * 516 * <p> 517 * Defines the maximum value for a parameter of numeric types. 518 * <br>The value must be a valid JSON number. 519 * 520 * <p> 521 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 522 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 523 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 524 * 525 * <p> 526 * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>. 527 * 528 * <h5 class='section'>Used for:</h5> 529 * <ul class='spaced-list'> 530 * <li> 531 * Server-side schema-based parsing validation. 532 * <li> 533 * Server-side generated Swagger documentation. 534 * <li> 535 * Client-side schema-based serializing validation. 536 * </ul> 537 */ 538 String maximum() default ""; 539 540 /** 541 * Synonym for {@link #maximum()}. 542 */ 543 String max() default ""; 544 545 /** 546 * <mk>exclusiveMaximum</mk> field of the {@doc ExtSwaggerParameterObject}. 547 * 548 * <p> 549 * Defines whether the maximum is matched exclusively. 550 * 551 * <p> 552 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 553 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 554 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 555 * 556 * <p> 557 * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>. 558 * <br>If <jk>true</jk>, must be accompanied with <c>maximum</c>. 559 * 560 * <h5 class='section'>Used for:</h5> 561 * <ul class='spaced-list'> 562 * <li> 563 * Server-side schema-based parsing validation. 564 * <li> 565 * Server-side generated Swagger documentation. 566 * <li> 567 * Client-side schema-based serializing validation. 568 * </ul> 569 */ 570 boolean exclusiveMaximum() default false; 571 572 /** 573 * Synonym for {@link #exclusiveMaximum()}. 574 */ 575 boolean emax() default false; 576 577 /** 578 * <mk>minimum</mk> field of the {@doc ExtSwaggerParameterObject}. 579 * 580 * <p> 581 * Defines the minimum value for a parameter of numeric types. 582 * <br>The value must be a valid JSON number. 583 * 584 * <p> 585 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 586 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 587 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 588 * 589 * <p> 590 * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>. 591 * 592 * <h5 class='section'>Used for:</h5> 593 * <ul class='spaced-list'> 594 * <li> 595 * Server-side schema-based parsing validation. 596 * <li> 597 * Server-side generated Swagger documentation. 598 * <li> 599 * Client-side schema-based serializing validation. 600 * </ul> 601 */ 602 String minimum() default ""; 603 604 /** 605 * Synonym for {@link #minimum()}. 606 */ 607 String min() default ""; 608 609 /** 610 * <mk>exclusiveMinimum</mk> field of the {@doc ExtSwaggerParameterObject}. 611 * 612 * <p> 613 * Defines whether the minimum is matched exclusively. 614 * 615 * <p> 616 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 617 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 618 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 619 * 620 * <p> 621 * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>. 622 * <br>If <jk>true</jk>, Must be accompanied with <c>minimum</c>. 623 * 624 * <h5 class='section'>Used for:</h5> 625 * <ul class='spaced-list'> 626 * <li> 627 * Server-side schema-based parsing validation. 628 * <li> 629 * Server-side generated Swagger documentation. 630 * <li> 631 * Client-side schema-based serializing validation. 632 * </ul> 633 */ 634 boolean exclusiveMinimum() default false; 635 636 /** 637 * Synonym for {@link #exclusiveMinimum()}. 638 */ 639 boolean emin() default false; 640 641 /** 642 * <mk>maxLength</mk> field of the {@doc ExtSwaggerParameterObject}. 643 * 644 * <p> 645 * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. 646 * <br>The length of a string instance is defined as the number of its characters as defined by <a href='https://tools.ietf.org/html/rfc4627'>RFC 4627</a>. 647 * <br>The value <c>-1</c> is always ignored. 648 * 649 * <p> 650 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 651 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 652 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 653 * 654 * <p> 655 * Only allowed for the following types: <js>"string"</js>. 656 * 657 * <h5 class='section'>Used for:</h5> 658 * <ul class='spaced-list'> 659 * <li> 660 * Server-side schema-based parsing validation. 661 * <li> 662 * Server-side generated Swagger documentation. 663 * <li> 664 * Client-side schema-based serializing validation. 665 * </ul> 666 */ 667 long maxLength() default -1; 668 669 /** 670 * Synonym for {@link #maxLength()}. 671 */ 672 long maxl() default -1; 673 674 /** 675 * <mk>minLength</mk> field of the {@doc ExtSwaggerParameterObject}. 676 * 677 * <p> 678 * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. 679 * <br>The length of a string instance is defined as the number of its characters as defined by <a href='https://tools.ietf.org/html/rfc4627'>RFC 4627</a>. 680 * <br>The value <c>-1</c> is always ignored. 681 * 682 * <p> 683 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 684 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 685 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 686 * 687 * <p> 688 * Only allowed for the following types: <js>"string"</js>. 689 * 690 * <h5 class='section'>Used for:</h5> 691 * <ul class='spaced-list'> 692 * <li> 693 * Server-side schema-based parsing validation. 694 * <li> 695 * Server-side generated Swagger documentation. 696 * <li> 697 * Client-side schema-based serializing validation. 698 * </ul> 699 */ 700 long minLength() default -1; 701 702 /** 703 * Synonym for {@link #minLength()}. 704 */ 705 long minl() default -1; 706 707 /** 708 * <mk>pattern</mk> field of the {@doc ExtSwaggerParameterObject}. 709 * 710 * <p> 711 * A string input is valid if it matches the specified regular expression pattern. 712 * 713 * <p> 714 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 715 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 716 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 717 * 718 * <p> 719 * Only allowed for the following types: <js>"string"</js>. 720 * 721 * <h5 class='section'>Used for:</h5> 722 * <ul class='spaced-list'> 723 * <li> 724 * Server-side schema-based parsing validation. 725 * <li> 726 * Server-side generated Swagger documentation. 727 * <li> 728 * Client-side schema-based serializing validation. 729 * </ul> 730 */ 731 String pattern() default ""; 732 733 /** 734 * Synonym for {@link #pattern()}. 735 */ 736 String p() default ""; 737 738 /** 739 * <mk>maxItems</mk> field of the {@doc ExtSwaggerParameterObject}. 740 * 741 * <p> 742 * An array or collection is valid if its size is less than, or equal to, the value of this keyword. 743 * 744 * <p> 745 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 746 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 747 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 748 * 749 * <p> 750 * Only allowed for the following types: <js>"array"</js>. 751 * 752 * <h5 class='section'>Used for:</h5> 753 * <ul class='spaced-list'> 754 * <li> 755 * Server-side schema-based parsing validation. 756 * <li> 757 * Server-side generated Swagger documentation. 758 * <li> 759 * Client-side schema-based serializing validation. 760 * </ul> 761 */ 762 long maxItems() default -1; 763 764 /** 765 * Synonym for {@link #maxItems()}. 766 */ 767 long maxi() default -1; 768 769 /** 770 * <mk>minItems</mk> field of the {@doc ExtSwaggerParameterObject}. 771 * 772 * <p> 773 * An array or collection is valid if its size is greater than, or equal to, the value of this keyword. 774 * 775 * <p> 776 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 777 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 778 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 779 * 780 * <p> 781 * Only allowed for the following types: <js>"array"</js>. 782 * 783 * <h5 class='section'>Used for:</h5> 784 * <ul class='spaced-list'> 785 * <li> 786 * Server-side schema-based parsing validation. 787 * <li> 788 * Server-side generated Swagger documentation. 789 * <li> 790 * Client-side schema-based serializing validation. 791 * </ul> 792 */ 793 long minItems() default -1; 794 795 /** 796 * Synonym for {@link #minItems()}. 797 */ 798 long mini() default -1; 799 800 /** 801 * <mk>uniqueItems</mk> field of the {@doc ExtSwaggerParameterObject}. 802 * 803 * <p> 804 * If <jk>true</jk> the input validates successfully if all of its elements are unique. 805 * 806 * <p> 807 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 808 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 809 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 810 * 811 * <p> 812 * If the parameter type is a subclass of {@link Set}, this validation is skipped (since a set can only contain unique items anyway). 813 * <br>Otherwise, the collection or array is checked for duplicate items. 814 * 815 * <p> 816 * Only allowed for the following types: <js>"array"</js>. 817 * 818 * <h5 class='section'>Used for:</h5> 819 * <ul class='spaced-list'> 820 * <li> 821 * Server-side schema-based parsing validation. 822 * <li> 823 * Server-side generated Swagger documentation. 824 * <li> 825 * Client-side schema-based serializing validation. 826 * </ul> 827 */ 828 boolean uniqueItems() default false; 829 830 /** 831 * Synonym for {@link #uniqueItems()}. 832 */ 833 boolean ui() default false; 834 835 /** 836 * <mk>enum</mk> field of the {@doc ExtSwaggerParameterObject}. 837 * 838 * <p> 839 * If specified, the input validates successfully if it is equal to one of the elements in this array. 840 * 841 * <p> 842 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 843 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 844 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 845 * 846 * <p> 847 * The format is a {@doc SimplifiedJson} array or comma-delimited list. 848 * <br>Multiple lines are concatenated with newlines. 849 * 850 * <h5 class='section'>Examples:</h5> 851 * <p class='bcode w800'> 852 * <jc>// Comma-delimited list</jc> 853 * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/pet/findByStatus/{status}"</js>) 854 * <jk>public</jk> Collection<Pet> findPetsByStatus( 855 * <ja>@Path</ja>( 856 * name=<js>"status"</js>, 857 * _enum=<js>"AVAILABLE,PENDING,SOLD"</js>, 858 * ) PetStatus status 859 * ) {...} 860 * </p> 861 * <p class='bcode w800'> 862 * <jc>// JSON array</jc> 863 * <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/pet/findByStatus/{status}"</js>) 864 * <jk>public</jk> Collection<Pet> findPetsByStatus( 865 * <ja>@Path</ja>( 866 * name=<js>"status"</js>, 867 * _enum=<js>"['AVAILABLE','PENDING','SOLD']"</js>, 868 * ) PetStatus status 869 * ) {...} 870 * </p> 871 * 872 * <h5 class='section'>Used for:</h5> 873 * <ul class='spaced-list'> 874 * <li> 875 * Server-side schema-based parsing validation. 876 * <li> 877 * Server-side generated Swagger documentation. 878 * <li> 879 * Client-side schema-based serializing validation. 880 * </ul> 881 */ 882 String[] _enum() default {}; 883 884 /** 885 * Synonym for {@link #_enum()}. 886 */ 887 String[] e() default {}; 888 889 /** 890 * <mk>multipleOf</mk> field of the {@doc ExtSwaggerParameterObject}. 891 * 892 * <p> 893 * A numeric instance is valid if the result of the division of the instance by this keyword's value is an integer. 894 * <br>The value must be a valid JSON number. 895 * 896 * <p> 897 * If validation fails during serialization or parsing, the part serializer/parser will throw a {@link SchemaValidationException}. 898 * <br>On the client-side, this gets converted to a <c>RestCallException</c> which is thrown before the connection is made. 899 * <br>On the server-side, this gets converted to a <c>BadRequest</c> (400). 900 * 901 * <p> 902 * Only allowed for the following types: <js>"integer"</js>, <js>"number"</js>. 903 * 904 * <h5 class='section'>Used for:</h5> 905 * <ul class='spaced-list'> 906 * <li> 907 * Server-side schema-based parsing validation. 908 * <li> 909 * Server-side generated Swagger documentation. 910 * <li> 911 * Client-side schema-based serializing validation. 912 * </ul> 913 */ 914 String multipleOf() default ""; 915 916 /** 917 * Synonym for {@link #multipleOf()}. 918 */ 919 String mo() default ""; 920 921 //================================================================================================================= 922 // Other 923 //================================================================================================================= 924 925 /** 926 * A serialized example of the parameter. 927 * 928 * <p> 929 * This attribute defines a representation of the value that is used by <c>BasicRestInfoProvider</c> to construct 930 * an example of parameter. 931 * 932 * <h5 class='section'>Example:</h5> 933 * <p class='bcode w800'> 934 * <ja>@Path</ja>( 935 * name=<js>"status"</js>, 936 * type=<js>"array"</js>, 937 * collectionFormat=<js>"csv"</js>, 938 * example=<js>"AVALIABLE,PENDING"</js> 939 * ) 940 * PetStatus[] status 941 * </p> 942 * 943 * <p> 944 * If not specified, Juneau will automatically create examples from sample POJOs serialized using the registered {@link HttpPartSerializer}. 945 * <br> 946 * 947 * </p> 948 * <h5 class='section'>Used for:</h5> 949 * <ul class='spaced-list'> 950 * <li> 951 * Server-side generated Swagger documentation. 952 * </ul> 953 * 954 * <ul class='seealso'> 955 * <li class='ja'>{@link Example} 956 * <li class='jc'>{@link BeanContext} 957 * <ul> 958 * <li class='jf'>{@link BeanContext#BEAN_examples BEAN_examples} 959 * </ul> 960 * <li class='jc'>{@link JsonSchemaSerializer} 961 * <ul> 962 * <li class='jf'>{@link JsonSchemaGenerator#JSONSCHEMA_addExamplesTo JSONSCHEMA_addExamplesTo} 963 * <li class='jf'>{@link JsonSchemaGenerator#JSONSCHEMA_allowNestedExamples JSONSCHEMA_allowNestedExamples} 964 * </ul> 965 * </ul> 966 * 967 * <ul class='notes'> 968 * <li> 969 * The format is a {@doc SimplifiedJson} object or plain text string. 970 * <br>Multiple lines are concatenated with newlines. 971 * <li> 972 * Supports {@doc RestSvlVariables} 973 * (e.g. <js>"$L{my.localized.variable}"</js>). 974 * </ul> 975 */ 976 String[] example() default {}; 977 978 /** 979 * Synonym for {@link #example()}. 980 */ 981 String[] ex() default {}; 982 983 /** 984 * Free-form value for the {@doc ExtSwaggerParameterObject}. 985 * 986 * <p> 987 * This is a {@doc SimplifiedJson} object that makes up the swagger information for this field. 988 * 989 * <p> 990 * The following are completely equivalent ways of defining the swagger description of the Path object: 991 * <p class='bcode w800'> 992 * <jc>// Normal</jc> 993 * <ja>@Path</ja>( 994 * name=<js>"orderId"</js>, 995 * description=<js>"ID of order to fetch"</js>, 996 * maximum=<js>"1000"</js>, 997 * minimum=<js>"101"</js>, 998 * example=<js>"123"</js> 999 * ) 1000 * </p> 1001 * <p class='bcode w800'> 1002 * <jc>// Free-form</jc> 1003 * <ja>@Path</ja>({ 1004 * name=<js>"orderId"</js>, 1005 * api={ 1006 * <js>"description: 'ID of order to fetch',"</js>, 1007 * <js>"maximum: 1000,"</js>, 1008 * <js>"minimum: 101,"</js>, 1009 * <js>"example: 123"</js> 1010 * } 1011 * ) 1012 * </p> 1013 * <p class='bcode w800'> 1014 * <jc>// Free-form using variables</jc> 1015 * <ja>@Path</ja>({ 1016 * name=<js>"orderId"</js>, 1017 * api=<js>"$L{orderIdSwagger}"</js> 1018 * ) 1019 * </p> 1020 * <p class='bcode w800'> 1021 * <mc>// Contents of MyResource.properties</mc> 1022 * <mk>orderIdSwagger</mk> = <mv>{ description: "ID of order to fetch", maximum: 1000, minimum: 101, example: 123 }</mv> 1023 * </p> 1024 * 1025 * <p> 1026 * The reasons why you may want to use this field include: 1027 * <ul> 1028 * <li>You want to pull in the entire Swagger JSON definition for this field from an external source such as a properties file. 1029 * <li>You want to add extra fields to the Swagger documentation that are not officially part of the Swagger specification. 1030 * </ul> 1031 * 1032 * <h5 class='section'>Used for:</h5> 1033 * <ul class='spaced-list'> 1034 * <li> 1035 * Server-side generated Swagger documentation. 1036 * </ul> 1037 * 1038 * <ul class='notes'> 1039 * <li> 1040 * Note that the only swagger field you can't specify using this value is <js>"name"</js> whose value needs to be known during servlet initialization. 1041 * <li> 1042 * The format is a {@doc SimplifiedJson} object. 1043 * <li> 1044 * Automatic validation is NOT performed on input based on attributes in this value. 1045 * <li> 1046 * The leading/trailing <c>{ }</c> characters are optional. 1047 * <br>The following two example are considered equivalent: 1048 * <p class='bcode w800'> 1049 * <ja>@Path</ja>(api=<js>"{description: 'ID of order to fetch'}"</js>) 1050 * </p> 1051 * <p class='bcode w800'> 1052 * <ja>@Path</ja>(api=<js>"description: 'ID of order to fetch''"</js>) 1053 * </p> 1054 * <li> 1055 * Multiple lines are concatenated with newlines so that you can format the value to be readable. 1056 * <li> 1057 * Supports {@doc RestSvlVariables} 1058 * (e.g. <js>"$L{my.localized.variable}"</js>). 1059 * <li> 1060 * Values defined in this field supersede values pulled from the Swagger JSON file and are superseded by individual values defined on this annotation. 1061 * </ul> 1062 */ 1063 String[] api() default {}; 1064}