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

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

// ***************************************************************************************************************************
// * 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.http.annotation;

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

import java.lang.annotation.*;

import org.apache.juneau.annotation.*;
import org.apache.juneau.httppart.*;
import org.apache.juneau.oapi.*;

/**
 * REST response annotation.
 *
 * 

* Identifies an interface to use to interact with HTTP parts of an HTTP response through a bean. * *

* Can be used in the following locations: *

    *
  • Exception classes thrown from server-side @RestOp-annotated methods. *
  • Return type classes of server-side @RestOp-annotated methods. *
  • Arguments and argument-types of server-side @RestOp-annotated methods. *
  • Return type classes of server-side @RemoteOp-annotated methods. *
  • Client-side @RemoteOp-annotated methods. *
  • Return type interfaces of client-side @RemoteOp-annotated methods. *
* *
See Also:
*/ @Documented @Target({PARAMETER,TYPE,METHOD}) @Retention(RUNTIME) @Inherited @Repeatable(ResponseAnnotation.Array.class) @ContextApply(ResponseAnnotation.Applier.class) public @interface Response { /** * Serialized examples of the body of a response. * *

* This is a Swagger object whose keys are media types and values are string representations of that value. * *

* // A JSON representation of a PetCreate object. * @Response( * examples={ * "'application/json':'{name:\\'Doggie\\',species:\\'Dog\\'}',", * "'text/uon':'(name:Doggie,species=Dog)'" * } * ) *

* *
Used for:
*
    *
  • * Server-side generated Swagger documentation. *
* *
Notes:
    *
  • * The format is a Swagger object with string keys (media type) and string values (example for that media type) . *
  • * The leading/trailing { } characters are optional. *
  • * Multiple lines are concatenated with newlines so that you can format the value to be readable: *
  • * Supports SVL Variables (e.g. "$L{my.localized.variable}") for the swagger generator. *
  • * Resolution of variables is delayed until request time and occurs before parsing. *
    This allows you to, for example, pull in a JSON construct from a properties file based on the locale of the HTTP request. *
* * @return The annotation value. */ String[] examples() default {}; /** * headers field of the Swagger Response Object. * *
Used for:
*
    *
  • * Server-side generated Swagger documentation. *
* * @return The annotation value. */ Header[] headers() default {}; /** * Dynamically apply this annotation to the specified classes. * *
See Also:
* * @return The annotation value. */ String[] on() default {}; /** * Dynamically apply this annotation to the specified classes. * *

* Identical to {@link #on()} except allows you to specify class objects instead of a strings. * *

See Also:
* * @return The annotation value. */ Class[] onClass() default {}; /** * Specifies the {@link HttpPartParser} class used for parsing strings to values. * *

* Overrides for this part the part parser defined on the REST resource which by default is {@link OpenApiParser}. * * @return The annotation value. */ Class parser() default HttpPartParser.Void.class; /** * schema field of the Swagger Response Object. * *

Used for:
*
    *
  • * Server-side schema-based serializing and serializing validation. *
  • * Server-side generated Swagger documentation. *
* * @return The annotation value. */ Schema schema() default @Schema; /** * Specifies the {@link HttpPartSerializer} class used for serializing values to strings. * *

* Overrides for this part the part serializer defined on the REST resource which by default is {@link OpenApiSerializer}. * * @return The annotation value. */ Class serializer() default HttpPartSerializer.Void.class; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy