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