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