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.RetentionPolicy.*;
016
017import java.lang.annotation.*;
018
019/**
020 * Swagger contact annotation.
021 *
022 * <p>
023 * The contact information for the exposed API.
024 *
025 * <p>
026 * Used to populate the auto-generated Swagger documentation and UI for server-side <ja>@Rest</ja>-annotated classes.
027 *
028 * <h5 class='section'>Examples:</h5>
029 * <p class='bcode w800'>
030 *    <jc>// Normal</jc>
031 *    <ja>@Rest</ja>(
032 *       swagger=<ja>@ResourceSwagger</ja>(
033 *          contact=<ja>@Contact</ja>(
034 *             name=<js>"Juneau Development Team"</js>,
035 *             email=<js>"dev@juneau.apache.org"</js>,
036 *             url=<js>"http://juneau.apache.org"</js>
037 *          )
038 *       )
039 *    )
040 * </p>
041 * <p class='bcode w800'>
042 *    <jc>// Free-form</jc>
043 *    <ja>@Rest</ja>(
044 *       swagger=<ja>@ResourceSwagger</ja>(
045 *          contact=<ja>@Contact</ja>({
046 *             <js>"name:'Juneau Development Team',"</js>,
047 *             <js>"email:'dev@juneau.apache.org',"</js>,
048 *             <js>"url:'http://juneau.apache.org',"</js>,
049 *             <js>"x-extra:'extra field'"</js>
050 *          })
051 *       )
052 *    )
053 * </p>
054 *
055 * <ul class='seealso'>
056 *    <li class='link'>{@doc juneau-rest-server.Swagger}
057 *    <li class='extlink'>{@doc SwaggerContactObject}
058 * </ul>
059 */
060@Documented
061@Retention(RUNTIME)
062public @interface Contact {
063
064   /**
065    * <mk>name</mk> field of the {@doc SwaggerContactObject}.
066    *
067    * <p>
068    * The identifying name of the contact person/organization.
069    *
070    * <ul class='notes'>
071    *    <li>
072    *       The format is a plain-text string.
073    *    <li>
074    *       Supports {@doc DefaultRestSvlVariables}
075    *       (e.g. <js>"$L{my.localized.variable}"</js>).
076    * </ul>
077    */
078   String name() default "";
079
080   /**
081    * <mk>url</mk> field of the {@doc SwaggerContactObject}.
082    *
083    * <p>
084    * The URL pointing to the contact information. MUST be in the format of a URL.
085    *
086    * <ul class='notes'>
087    *    <li>
088    *       The format is a URL string.
089    *    <li>
090    *       Supports {@doc DefaultRestSvlVariables}
091    *       (e.g. <js>"$L{my.localized.variable}"</js>).
092    * </ul>
093    */
094   String url() default "";
095
096   /**
097    * <mk>email</mk> field of the {@doc SwaggerContactObject}.
098    *
099    * <p>
100    * The email address of the contact person/organization. MUST be in the format of an email address.
101    *
102    * <ul class='notes'>
103    *    <li>
104    *       The format is an email string.
105    *    <li>
106    *       Supports {@doc DefaultRestSvlVariables}
107    *       (e.g. <js>"$L{my.localized.variable}"</js>).
108    * </ul>
109    */
110   String email() default "";
111
112   /**
113    * Free-form value for the {@doc SwaggerContactObject}.
114    *
115    * <p>
116    * This is a JSON object that makes up the swagger information for this field.
117    *
118    * <p>
119    * The following are completely equivalent ways of defining the swagger description of the contact information:
120    * <p class='bcode w800'>
121    *    <jc>// Normal</jc>
122    *    <ja>@Rest</ja>(
123    *       swagger=<ja>@ResourceSwagger</ja>(
124    *          contact=<ja>@Contact</ja>(
125    *             name=<js>"Juneau Development Team"</js>,
126    *             email=<js>"dev@juneau.apache.org"</js>,
127    *             url=<js>"http://juneau.apache.org"</js>
128    *          )
129    *       )
130    *    )
131    * </p>
132    * <p class='bcode w800'>
133    *    <jc>// Free-form</jc>
134    *    <ja>@Rest</ja>(
135    *       swagger=<ja>@ResourceSwagger</ja>(
136    *          contact=<ja>@Contact</ja>({
137    *             <js>"name: 'Juneau Development Team',"</js>,
138    *             <js>"email: 'dev@juneau.apache.org',"</js>,
139    *             <js>"url: 'http://juneau.apache.org'"</js>,
140    *          })
141    *       )
142    *    )
143    * </p>
144    * <p class='bcode w800'>
145    *    <jc>// Free-form with variables</jc>
146    *    <ja>@Rest</ja>(
147    *       swagger=<ja>@ResourceSwagger</ja>(
148    *          contact=<ja>@Contact</ja>(<js>"$L{contactSwagger}"</js>)
149    *    )
150    * </p>
151    * <p class='bcode w800'>
152    *    <mc>// Contents of MyResource.properties</mc>
153    *    <mk>contactSwagger</mk> = <mv>{ name: "Juneau Development Team", email: "dev@juneau.apache.org", url: "http://juneau.apache.org" }</mv>
154    * </p>
155    *
156    * <p>
157    *    The reasons why you may want to use this field include:
158    * <ul>
159    *    <li>You want to pull in the entire Swagger JSON definition for this field from an external source such as a properties file.
160    *    <li>You want to add extra fields to the Swagger documentation that are not officially part of the Swagger specification.
161    * </ul>
162    *
163    * <ul class='notes'>
164    *    <li>
165    *       The format is a {@doc SimpleJson} object.
166    *    <li>
167    *       The leading/trailing <c>{ }</c> characters are optional.
168    *       <br>The following two example are considered equivalent:
169    *       <p class='bcode w800'>
170    *    <ja>@Contact</ja>(<js>"{name: 'Juneau Development Team'}"</js>)
171    *       </p>
172    *       <p class='bcode w800'>
173    *    <ja>@Contact</ja>(<js>"name: 'Juneau Development Team'"</js>)
174    *       </p>
175    *    <li>
176    *       Multiple lines are concatenated with newlines so that you can format the value to be readable.
177    *    <li>
178    *       Supports {@doc DefaultRestSvlVariables}
179    *       (e.g. <js>"$L{my.localized.variable}"</js>).
180    *    <li>
181    *       Values defined in this field supersede values pulled from the Swagger JSON file and are superseded by individual values defined on this annotation.
182    * </ul>
183    */
184   String[] value() default {};
185}