001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.examples.rest.dto;
014
015import org.apache.juneau.jsonschema.annotation.ExternalDocs;
016import org.apache.juneau.dto.*;
017import org.apache.juneau.examples.rest.petstore.dto.*;
018import org.apache.juneau.http.annotation.*;
019import org.apache.juneau.rest.*;
020import org.apache.juneau.rest.annotation.*;
021import org.apache.juneau.rest.helper.*;
022import org.apache.juneau.rest.widget.*;
023
024/**
025 * Sample REST resource for rendering predefined label beans.
026 */
027@RestResource(
028   path="/predefinedLabels",
029   title="Predefined Label Beans",
030   description="Shows examples of predefined label beans",
031   htmldoc=@HtmlDoc(
032      widgets={
033         ContentTypeMenuItem.class,
034         ThemeMenuItem.class
035      },
036      navlinks={
037         "up: request:/..",
038         "options: servlet:/?method=OPTIONS",
039         "$W{ContentTypeMenuItem}",
040         "$W{ThemeMenuItem}",
041         "source: $C{Source/gitHub}/org/apache/juneau/examples/rest/dto/$R{servletClassSimple}.java"
042      }
043   ),
044   swagger=@ResourceSwagger(
045      contact=@Contact(name="Juneau Developer",email="dev@juneau.apache.org"),
046      license=@License(name="Apache 2.0",url="http://www.apache.org/licenses/LICENSE-2.0.html"),
047      version="2.0",
048      termsOfService="You are on your own.",
049      externalDocs=@ExternalDocs(description="Apache Juneau",url="http://juneau.apache.org")
050   )
051)
052public class PredefinedLabelsResource extends BasicRestServlet {
053   private static final long serialVersionUID = 1L;
054
055   @RestMethod
056   public ResourceDescriptions get() throws Exception {
057      return new ResourceDescriptions()
058         .append("beanDescription", "BeanDescription")
059         .append("htmlLinks", "HtmlLink")
060      ;
061   }
062
063   @RestMethod
064   public BeanDescription getBeanDescription() throws Exception {
065      return new BeanDescription(Pet.class);
066   }
067
068   @RestMethod
069   public LinkString[] getHtmlLinks() throws Exception {
070      return new LinkString[] {
071         new LinkString("apache", "http://apache.org"),
072         new LinkString("juneau", "http://juneau.apache.org")
073      };
074   }
075}