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