001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.http.annotation;
018
019import static java.lang.annotation.ElementType.*;
020import static java.lang.annotation.RetentionPolicy.*;
021
022import java.lang.annotation.*;
023
024import org.apache.juneau.annotation.*;
025import org.apache.juneau.httppart.*;
026import org.apache.juneau.oapi.*;
027
028/**
029 * REST request path remainder annotation.
030 *
031 * <p>
032 * Identifies a POJO to be used as the path remainder (the part after the path match) on an HTTP request.
033 *
034 * <p>
035 * This is a specialized shortcut for <c><ja>@Path</ja>(<js>"/*"</js>)</c>.
036 *
037 * <p>
038 * Can be used in the following locations:
039 * <ul>
040 *    <li>Arguments and argument-types of server-side <ja>@RestOp</ja>-annotated methods.
041 *    <li>Arguments and argument-types of client-side <ja>@RemoteResource</ja>-annotated interfaces.
042 *    <li>Methods and return types of server-side and client-side <ja>@Request</ja>-annotated interfaces.
043 * </ul>
044 *
045 * <h5 class='topic'>Arguments and argument-types of server-side @RestOp-annotated methods</h5>
046 * <p>
047 * Annotation that can be applied to a parameter of a <ja>@RestOp</ja>-annotated method to identify it as the
048 * path remainder after the path pattern match.
049 *
050 * <h5 class='section'>Example:</h5>
051 * <p class='bjava'>
052 *    <ja>@RestGet</ja>(<js>"/myurl/{foo}/{bar}/*"</js>)
053 *    <jk>public void</jk> doGet(
054 *          <ja>@Path</ja>(<js>"foo"</js>) String <jv>foo</jv>,
055 *          <ja>@Path</ja>(<js>"bar"</js>) <jk>int</jk> <jv>bar</jv>,
056 *          <ja>@PathRemainder</ja> String <jv>remainder</jv>,  <jc>// Equivalent to @Path("/*")</jc>
057 *       ) {...}
058 * </p>
059 *
060 * <p>
061 * This is functionally equivalent to using <c><ja>@Path</ja>(<js>"/*"</js>)</c>, but provides a more intuitive name.
062 *
063 * <h5 class='section'>See Also:</h5><ul>
064 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/Path">@Path</a>
065 * </ul>
066 *
067 * <h5 class='topic'>Arguments and argument-types of client-side @RemoteResource-annotated interfaces</h5>
068 * <p>
069 * Annotation applied to Java method arguments of interface proxies to denote that they represent the path remainder on the request.
070 *
071 * <h5 class='section'>See Also:</h5><ul>
072 * </ul>
073 *
074 * <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5>
075 * <p>
076 * <h5 class='section'>See Also:</h5><ul>
077 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/Request">@Request</a>
078 * </ul>
079 *
080 * <h5 class='section'>See Also:</h5><ul>
081 *    <li class='ja'>{@link Path}
082 * </ul>
083 *
084 * @since 9.2.0
085 */
086@Documented
087@Target({ PARAMETER, METHOD, TYPE, FIELD })
088@Retention(RUNTIME)
089@Inherited
090@Repeatable(PathRemainderAnnotation.Array.class)
091@ContextApply(PathRemainderAnnotation.Applier.class)
092public @interface PathRemainder {
093
094   /**
095    * Default value for this parameter.
096    *
097    * @return The annotation value.
098    */
099   String def() default "";
100
101   /**
102    * Optional description for the exposed API.
103    *
104    * @return The annotation value.
105    */
106   String[] description() default {};
107
108   /**
109    * Dynamically apply this annotation to the specified classes.
110    *
111    * <h5 class='section'>See Also:</h5><ul>
112    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
113    * </ul>
114    *
115    * @return The annotation value.
116    */
117   String[] on() default {};
118
119   /**
120    * Dynamically apply this annotation to the specified classes.
121    *
122    * <p>
123    * Identical to {@link #on()} except allows you to specify class objects instead of a strings.
124    *
125    * <h5 class='section'>See Also:</h5><ul>
126    *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/DynamicallyAppliedAnnotations">Dynamically Applied Annotations</a>
127    * </ul>
128    *
129    * @return The annotation value.
130    */
131   Class<?>[] onClass() default {};
132
133   /**
134    * Specifies the {@link HttpPartParser} class used for parsing strings to values.
135    *
136    * <p>
137    * Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}.
138    *
139    * @return The annotation value.
140    */
141   Class<? extends HttpPartParser> parser() default HttpPartParser.Void.class;
142
143   /**
144    * <mk>schema</mk> field of the <a class='doclink' href='https://swagger.io/specification/v2#parameterObject'>Swagger Parameter Object</a>.
145    *
146    * <p>
147    * The schema defining the type used for parameter.
148    *
149    * <p>
150    * The {@link Schema @Schema} annotation can also be used standalone on the parameter or type.
151    * Values specified on this field override values specified on the type, and values specified on child types override values
152    * specified on parent types.
153    *
154    * <h5 class='section'>Used for:</h5>
155    * <ul class='spaced-list'>
156    *    <li>
157    *       Server-side schema-based parsing and parsing validation.
158    *    <li>
159    *       Server-side generated Swagger documentation.
160    *    <li>
161    *       Client-side schema-based serializing and serializing validation.
162    * </ul>
163    *
164    * @return The annotation value.
165    */
166   Schema schema() default @Schema;
167
168   /**
169    * Specifies the {@link HttpPartSerializer} class used for serializing values to strings.
170    *
171    * <p>
172    * Overrides for this part the part serializer defined on the REST client which by default is {@link OpenApiSerializer}.
173    *
174    * @return The annotation value.
175    */
176   Class<? extends HttpPartSerializer> serializer() default HttpPartSerializer.Void.class;
177}