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