All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.rest.annotation.Response Maven / Gradle / Ivy

There is a newer version: 9.0.1
Show newest version
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
// * with the License.  You may obtain a copy of the License at                                                              *
// *                                                                                                                         *
// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
// *                                                                                                                         *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
// * specific language governing permissions and limitations under the License.                                              *
// ***************************************************************************************************************************
package org.apache.juneau.rest.annotation;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;

import java.lang.annotation.*;

import org.apache.juneau.rest.*;

/**
 * Annotation used in conjunction with {@link MethodSwagger#responses()} to identify possible responses by the method.
 *
 * 
Example:
*

* @RestMethod( * name="*", * swagger=@ResourceSwagger( * responses={ * @Response(value=200,description="Everything was great."), * @Response(value=404,description="File was not found.") * @Response(500), * } * ) * ) * public void doAnything(RestRequest req, RestResponse res, @Method String method) { * ... * } *

*/ @Documented @Target(PARAMETER) @Retention(RUNTIME) @Inherited public @interface Response { /** * HTTP response code. */ int value(); /** * Optional description. * *

* The default value pulls the description from the description entry in the servlet resource bundle. * (e.g. "myMethod.res.[code].description = foo" or * "MyServlet.myMethod.res.[code].description = foo"). * *

* This field can contain variables (e.g. "$L{my.localized.variable}"). *
See {@link RestContext#getVarResolver()} for the list of supported variables. * *

* Corresponds to the swagger field /paths/{path}/{method}/responses/{code}/description. */ String description() default ""; /** * A definition of the response structure. * *

* It can be a primitive, an array or an object. * If this field does not exist, it means no content is returned as part of the response. * As an extension to the Schema Object, * its root type value may also be "file". * This SHOULD be accompanied by a relevant produces mime-type. * *

Example:
*

* @RestMethod( * name="*", * swagger=@MethodSwagger( * responses={ * @Response(value=200,schema="{type:'string',description:'A serialized Person bean.'}"), * } * ) *

*/ String schema() default ""; /** * Optional response headers. * *

* Response variables can also be defined in the servlet resource bundle. * (e.g. "myMethod.res.[code].[category].[name] = foo" or * "MyServlet.myMethod.res.[code].[category].[name] = foo"). */ Parameter[] headers() default {}; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy