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 license annotation.
021 *
022 * <p>
023 * License 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 *          license=<ja>@License</ja>(
034 *             name=<js>"Apache 2.0"</js>,
035 *             url=<js>"http://www.apache.org/licenses/LICENSE-2.0.html"</js>
036 *          )
037 *       )
038 *    )
039 * </p>
040 * <p class='bcode w800'>
041 *    <jc>// Free-form</jc>
042 *    <ja>@Rest</ja>(
043 *       swagger=<ja>@ResourceSwagger</ja>(
044 *          license=<ja>@License</ja>({
045 *             <js>"name:'Apache 2.0',"</js>,
046 *             <js>"url:'http://www.apache.org/licenses/LICENSE-2.0.html'"</js>
047 *          })
048 *       )
049 *    )
050 * </p>
051 *
052 * <ul class='seealso'>
053 *    <li class='link'>{@doc juneau-rest-server.Swagger}
054 *    <li class='extlink'>{@doc SwaggerLicenseObject}
055 * </ul>
056 */
057@Documented
058@Retention(RUNTIME)
059public @interface License {
060
061   /**
062    * <mk>name</mk> field of the {@doc SwaggerLicenseObject}.
063    *
064    * <ul class='notes'>
065    *    <li>
066    *       The format is a plain-text string.
067    *    <li>
068    *       Supports {@doc DefaultRestSvlVariables}
069    *       (e.g. <js>"$L{my.localized.variable}"</js>).
070    * </ul>
071    */
072   String name() default "";
073
074   /**
075    * <mk>url</mk> field of the {@doc SwaggerLicenseObject}.
076    *
077    * <ul class='notes'>
078    *    <li>
079    *       The format is a plain-text string.
080    *    <li>
081    *       Supports {@doc DefaultRestSvlVariables}
082    *       (e.g. <js>"$L{my.localized.variable}"</js>).
083    * </ul>
084    */
085   String url() default "";
086
087   /**
088    * Free-form value for the {@doc SwaggerLicenseObject}.
089    *
090    * <p>
091    * This is a JSON object that makes up the swagger information for this field.
092    *
093    * <p>
094    * The following are completely equivalent ways of defining the swagger description of the license information:
095    * <p class='bcode w800'>
096    *    <jc>// Normal</jc>
097    *    <ja>@Rest</ja>(
098    *       swagger=<ja>@ResourceSwagger</ja>(
099    *          license=<ja>@License</ja>(
100    *             name=<js>"Apache 2.0"</js>,
101    *             url=<js>"http://www.apache.org/licenses/LICENSE-2.0.html"</js>
102    *          )
103    *       )
104    *    )
105    * </p>
106    * <p class='bcode w800'>
107    *    <jc>// Free-form</jc>
108    *    <ja>@Rest</ja>(
109    *       swagger=<ja>@ResourceSwagger</ja>(
110    *          license=<ja>@License</ja>({
111    *             <js>"name: 'Apache 2.0',"</js>,
112    *             <js>"url: 'http://www.apache.org/licenses/LICENSE-2.0.html'"</js>
113    *          })
114    *       )
115    *    )
116    * </p>
117    * <p class='bcode w800'>
118    *    <jc>// Free-form with variables</jc>
119    *    <ja>@Rest</ja>(
120    *       swagger=<ja>@ResourceSwagger</ja>(<js>"$L{licenseSwagger}"</js>)
121    *    )
122    * </p>
123    * <p class='bcode w800'>
124    *    <mc>// Contents of MyResource.properties</mc>
125    *    <mk>licenseSwagger</mk> = <mv>{ name: "Apache 2.0", url: "http://www.apache.org/licenses/LICENSE-2.0.html" }</mv>
126    * </p>
127    *
128    * <p>
129    *    The reasons why you may want to use this field include:
130    * <ul>
131    *    <li>You want to pull in the entire Swagger JSON definition for this field from an external source such as a properties file.
132    *    <li>You want to add extra fields to the Swagger documentation that are not officially part of the Swagger specification.
133    * </ul>
134    *
135    * <ul class='notes'>
136    *    <li>
137    *       The format is a {@doc SimpleJson} object.
138    *    <li>
139    *       The leading/trailing <c>{ }</c> characters are optional.
140    *       <br>The following two example are considered equivalent:
141    *       <p class='bcode w800'>
142    *    <ja>@License</ja>(<js>"{name: 'Apache 2.0'}"</js>)
143    *       </p>
144    *       <p class='bcode w800'>
145    *    <ja>@License</ja>(<js>"name: 'Apache 2.0'"</js>)
146    *       </p>
147    *    <li>
148    *       Multiple lines are concatenated with newlines so that you can format the value to be readable.
149    *    <li>
150    *       Supports {@doc DefaultRestSvlVariables}
151    *       (e.g. <js>"$L{my.localized.variable}"</js>).
152    *    <li>
153    *       Values defined in this field supersede values pulled from the Swagger JSON file and are superseded by individual values defined on this annotation.
154    * </ul>
155    */
156   String[] value() default {};
157}