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.rest; 014 015import java.lang.reflect.Method; 016 017import org.apache.juneau.dto.swagger.*; 018import org.apache.juneau.rest.annotation.*; 019 020/** 021 * REST resource information provider. 022 * 023 * <p> 024 * Provides localized Swagger documentation and other related information about a REST resource. 025 * 026 * <h5 class='section'>See Also:</h5> 027 * <ul> 028 * <li class='jf'>{@link RestContext#REST_infoProvider} 029 * <li class='link'><a class="doclink" href="../../../../overview-summary.html#juneau-rest-server.OptionsPages">Overview > juneau-rest-server > OPTIONS Pages</a> 030 * </ul> 031 */ 032public interface RestInfoProvider { 033 034 /** 035 * Represents no RestInfoProvider. 036 * 037 * <p> 038 * Used on annotation to indicate that the value should be inherited from the parent class, and 039 * ultimately {@link BasicRestInfoProvider} if not specified at any level. 040 */ 041 public interface Null extends RestInfoProvider {} 042 043 /** 044 * Returns the localized swagger for the REST resource. 045 * 046 * @param req The incoming HTTP request. 047 * @return 048 * A new {@link Swagger} instance. 049 * <br>Never <jk>null</jk>. 050 * @throws Exception 051 * Throw a {@link RestException} with a specific HTTP error status or any other exception 052 * to cause a <jsf>SC_INTERNAL_SERVER_ERROR</jsf>. 053 */ 054 public Swagger getSwagger(RestRequest req) throws Exception; 055 056 /** 057 * Returns the localized site name of the REST resource. 058 * 059 * @param req The current request. 060 * @return The localized site name of the REST resource, or <jk>null</jk> if none was found. 061 * @throws Exception 062 * Throw a {@link RestException} with a specific HTTP error status or any other exception 063 * to cause a <jsf>SC_INTERNAL_SERVER_ERROR</jsf>. 064 */ 065 public String getSiteName(RestRequest req) throws Exception; 066 067 /** 068 * Returns the localized title of the REST resource. 069 * 070 * @param req The current request. 071 * @return The localized title of the REST resource, or <jk>null</jk> if none was found. 072 * @throws Exception 073 * Throw a {@link RestException} with a specific HTTP error status or any other exception 074 * to cause a <jsf>SC_INTERNAL_SERVER_ERROR</jsf>. 075 */ 076 public String getTitle(RestRequest req) throws Exception; 077 078 /** 079 * Returns the localized description of the REST resource. 080 * 081 * @param req The current request. 082 * @return The localized description of the REST resource, or <jk>null</jk> if none was found. 083 * @throws Exception 084 * Throw a {@link RestException} with a specific HTTP error status or any other exception 085 * to cause a <jsf>SC_INTERNAL_SERVER_ERROR</jsf>. 086 */ 087 public String getDescription(RestRequest req) throws Exception; 088 089 /** 090 * Returns the localized summary of the specified java method. 091 * 092 * @param method The Java method annotated with {@link RestMethod @RestMethod}. 093 * @param req The current request. 094 * @return The localized summary of the method, or <jk>null</jk> if none was found. 095 * @throws Exception 096 * Throw a {@link RestException} with a specific HTTP error status or any other exception 097 * to cause a <jsf>SC_INTERNAL_SERVER_ERROR</jsf>. 098 */ 099 public String getMethodSummary(Method method, RestRequest req) throws Exception; 100 101 /** 102 * Returns the localized description of the specified java method on this servlet. 103 * 104 * @param method The Java method annotated with {@link RestMethod @RestMethod}. 105 * @param req The current request. 106 * @return The localized description of the method, or <jk>null</jk> if none was was found. 107 * @throws Exception 108 * Throw a {@link RestException} with a specific HTTP error status or any other exception 109 * to cause a <jsf>SC_INTERNAL_SERVER_ERROR</jsf>. 110 */ 111 public String getMethodDescription(Method method, RestRequest req) throws Exception; 112}