| <!-- |
| /*************************************************************************************************************************** |
| * 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. |
| ***************************************************************************************************************************/ |
| --> |
| |
| {todo} |
| Responses |
| |
| <p> |
| Under the input parameters are listed the possible responses for the resource: |
| </p> |
| <img class='bordered w900' src='doc-files/juneau-rest-server.Swagger.Operations.3.png'> |
| <p> |
| The <c>200</c> response is determined by the return type on the method, in this case a collection of <c>Pet</c> objects: |
| </p> |
| <p class='bpcode w800'> |
| <ja>@RestGet</ja>( |
| path=<js>"/pet"</js>, |
| summary=<js>"All pets in the store"</js>, |
| ... |
| ) |
| <jk>public</jk> Collection<Pet> getPets() <jk>throws</jk> NotAcceptable { |
| <jk>return</jk> <jf>store</jf>.getPets(); |
| } |
| </p> |
| <p> |
| Note that additional responses can be specified by throwing exceptions annotated with the {@link oaj.http.annotation.Response @Response} annotation such |
| as this one: |
| </p> |
| <p class='bpcode w800'> |
| <ja>@Response</ja>(code=406, description=<js>"Not Acceptable"</js>) |
| <jk>public class</jk> NotAcceptable <jk>extends</jk> RestException {...} |
| </p> |
| <p> |
| Like input parameters, the Swagger for responses can be define in multiple locations such as: |
| </p> |
| <ul> |
| <li>{@link oaj.http.annotation.Response @Response} annotated classes, methods, and parameters. |
| <li>{@link oajr.annotation.Rest#swagger() @Rest(swagger)} / {@link oajr.annotation.RestOp#swagger() @RestOp(swagger)} annotations. |
| </ul> |
| |
| <ul class='seealso'> |
| <li class='link'>{@doc RestResponseAnnotation} |
| <li class='link'>{@doc RestResponseHeaderAnnotation} |
| <li class='link'>{@doc RestResponseStatusAnnotation} |
| </ul> |
| |
| |