    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.annotations;
    014
    015import static java.lang.annotation.RetentionPolicy.RUNTIME;
    016import static org.apache.tapestry5.ioc.annotations.AnnotationUseContext.PAGE;
    017
    018import java.lang.annotation.Documented;
    019import java.lang.annotation.ElementType;
    020import java.lang.annotation.Retention;
    021import java.lang.annotation.Target;
    022
    023import org.apache.tapestry5.ioc.annotations.UseWith;
    024import org.apache.tapestry5.services.HttpError;
    025import org.apache.tapestry5.services.rest.OpenApiDescriptionGenerator;
    026import org.apache.tapestry5.services.rest.OpenApiTypeDescriber;
    027
    028/**
    029 * Annotation that provides some information about REST event handler methods for OpenAPI
    030 * description generation. It can be used in methods and also in pages to define defaults
    031 * used by all methods without the annotation, except for {{@link #returnType()}.
    032 *
    033 * @see OpenApiDescriptionGenerator
    034 * @see OpenApiTypeDescriber
    035 */
    036@Target({ElementType.METHOD, ElementType.TYPE})
    037@Retention(RUNTIME)
    038@Documented
    039@UseWith({PAGE})
    040public @interface RestInfo
    041{
    042    /**
    043     * Defines the request body media types supported by the annotated REST event handler method.
    044     */
    045    String[] consumes() default "";
    046
    047    /**
    048     * Defines the media types of the responses provided by the annotated REST event handler method in
    049     * successful requests.
    050     */
    051    String[] produces() default "";
    052
    053    /**
    054     * Defines the return type of this REST event handler method in successful requests.
    055     * This is particularly useful for methods that have Object return type because
    056     * they may return non-response objects for error reasons, such as {@link HttpError}.
    057     */
    058    Class<?> returnType() default Object.class;
    059
    060}