001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.rest.server.config;
018
019import org.apache.juneau.commons.bean.*;
020import org.apache.juneau.marshall.*;
021import org.apache.juneau.marshall.bson.*;
022import org.apache.juneau.marshall.cbor.*;
023import org.apache.juneau.marshall.csv.*;
024import org.apache.juneau.marshall.hjson.*;
025import org.apache.juneau.marshall.hocon.*;
026import org.apache.juneau.marshall.html.*;
027import org.apache.juneau.marshall.ini.*;
028import org.apache.juneau.marshall.jcs.*;
029import org.apache.juneau.marshall.json.*;
030import org.apache.juneau.marshall.json5.*;
031import org.apache.juneau.marshall.json5l.*;
032import org.apache.juneau.marshall.jsonl.*;
033import org.apache.juneau.marshall.markdown.*;
034import org.apache.juneau.marshall.msgpack.*;
035import org.apache.juneau.marshall.oapi.*;
036import org.apache.juneau.marshall.parquet.*;
037import org.apache.juneau.marshall.plaintext.*;
038import org.apache.juneau.marshall.prototext.*;
039import org.apache.juneau.marshall.serializer.*;
040import org.apache.juneau.marshall.soap.*;
041import org.apache.juneau.marshall.toml.*;
042import org.apache.juneau.marshall.uon.*;
043import org.apache.juneau.marshall.urlencoding.*;
044import org.apache.juneau.marshall.xml.*;
045import org.apache.juneau.marshall.yaml.*;
046import org.apache.juneau.rest.server.*;
047import org.apache.juneau.rest.server.servlet.*;
048
049/**
050 * Predefined configuration for a REST resource that supports all languages
051 * and provides common default configuration values.
052 *
053 * <p>
054 *    Default settings defined:
055 * </p>
056 * <ul class='spaced-list'>
057 *    <li class='ja'>{@link Rest}:
058 *       <ul>
059 *          <li class='jma'>{@link Rest#serializers() serializers}:
060 *             <ul class='javatree'>
061 *                <li class='jc'>{@link HtmlDocSerializer}
062 *                <li class='jc'>{@link HtmlStrippedDocSerializer}
063 *                <li class='jc'>{@link HtmlSchemaDocSerializer}
064 *                <li class='jc'>{@link JsonSerializer}
065 *                <li class='jc'>{@link Json5Serializer}
066 *                <li class='jc'>{@link Json5lSerializer}
067 *                <li class='jc'>{@link JsonSchemaSerializer}
068 *                <li class='jc'>{@link XmlDocSerializer}
069 *                <li class='jc'>{@link UonSerializer}
070 *                <li class='jc'>{@link UrlEncodingSerializer}
071 *                <li class='jc'>{@link OpenApiSerializer}
072 *                <li class='jc'>{@link MsgPackSerializer}
073 *                <li class='jc'>{@link SoapXmlSerializer}
074 *                <li class='jc'>{@link PlainTextSerializer}
075 *             </ul>
076 *          </li>
077 *          <li class='jma'>{@link Rest#parsers() parsers}:
078 *             <ul class='javatree'>
079 *                <li class='jc'>{@link JsonParser}
080 *                <li class='jc'>{@link Json5Parser}
081 *                <li class='jc'>{@link Json5lParser}
082 *                <li class='jc'>{@link XmlParser}
083 *                <li class='jc'>{@link HtmlParser}
084 *                <li class='jc'>{@link UonParser}
085 *                <li class='jc'>{@link UrlEncodingParser}
086 *                <li class='jc'>{@link OpenApiParser}
087 *                <li class='jc'>{@link MsgPackParser}
088 *                <li class='jc'>{@link PlainTextParser}
089 *             </ul>
090 *          </li>
091 *          <li class='jma'>{@link Rest#config() config}:  <js>"$S{juneau.configFile,SYSTEM_DEFAULT}"</js>
092 *    </ul>
093 * </li>
094 *    <li class='ja'>{@link MarshalledConfig}:
095 *       <ul>
096 *          <li class='jma'>{@link BeanConfig#ignoreUnknownBeanProperties() ignoreUnknownBeanProperties}:  <js>"true"</js>
097 *       </ul>
098 *    </li>
099 *    <li class='ja'>{@link SerializerConfig}:
100 *       <ul>
101 *          <li class='jma'>{@link SerializerConfig#uriResolution() uriResolution}:  <js>"ROOT_RELATIVE"</js>
102 *       </ul>
103 *    </li>
104 *    <li class='ja'>{@link HtmlDocConfig}:
105 *       <ul>
106 *          <li class='jma'>{@link HtmlDocConfig#header() header}:  <js>"&lt;h1&gt;$RS{title}&lt;/h1&gt;&lt;h2&gt;$RS{operationSummary,description}&lt;/h2&gt;$C{REST/header}"</js>
107 *          <li class='jma'>{@link HtmlDocConfig#navlinks() navlinks}:  <js>"up: request:/.."</js>
108 *          <li class='jma'>{@link HtmlDocConfig#stylesheet() stylesheet}:  <js>"$C{REST/theme,servlet:/htdocs/themes/devops.css}"</js>
109 *          <li class='jma'>{@link HtmlDocConfig#head() head}:  <js>"$C{REST/head}"</js>
110 *          <li class='jma'>{@link HtmlDocConfig#footer() footer}:  <js>"$C{REST/footer}"</js>
111 *          <li class='jma'>{@link HtmlDocConfig#nowrap() nowrap}:  <js>"true"</js>
112 *       </ul>
113 *    </li>
114 * </ul>
115 *
116 * <p>
117 *    This annotation can be applied to REST resource classes to define common default configurations:
118 * </p>
119 * <p class='bjava'>
120 *    <jc>// Used on a top-level resource.</jc>
121 *    <ja>@Rest</ja>
122 *    <jk>public class</jk> MyResource <jk>extends</jk> RestServlet <jk>implements</jk> BasicUniversalConfig { ... }
123 * </p>
124 * <p class='bjava'>
125 *    <jc>// Used on a child resource.</jc>
126 *    <ja>@Rest</ja>
127 *    <jk>public class</jk> MyResource <jk>extends</jk> RestResource <jk>implements</jk> BasicUniversalConfig { ... }
128 * </p>
129 *
130 * <p>
131 *    Note that the framework will aggregate annotations defined on all classes in the class hierarchy with
132 *    values defined on child classes overriding values defined on parent classes.  That allows any values defined
133 *    on this interface to be overridden by annotations defined on the implemented class.
134 * </p>
135 *
136 * <h5 class='section'>See Also:</h5><ul>
137 *    <ul class='javatreec'>
138 *       <li class='jc'>{@link BasicRestServlet}
139 *       <li class='jc'>{@link BasicRestServletGroup}
140 *       <li class='jc'>{@link BasicRestResource}
141 *       <li class='jc'>{@link BasicRestResourceGroup}
142 * </ul>
143 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestAnnotatedClasses">@Rest-Annotated Class</a>
144 * </ul>
145 */
146// @formatter:off
147@Rest(
148
149   // Default serializers for all Java methods in the class.
150   serializers={
151      HtmlDocSerializer.class, // HTML must be listed first because Internet Explore does not include text/html in their Accept header.
152      HtmlStrippedDocSerializer.class,
153      HtmlSchemaDocSerializer.class,
154      HjsonSerializer.class,
155      HoconSerializer.class,
156      JsonSerializer.class,
157      JcsSerializer.class,
158      Json5Serializer.class,
159      Json5lSerializer.class,
160      JsonlSerializer.class,
161      JsonSchemaSerializer.class,
162      XmlDocSerializer.class,
163      UonSerializer.class,
164      UrlEncodingSerializer.class,
165      OpenApiSerializer.class,
166      BsonSerializer.class,
167      CborSerializer.class,
168      MsgPackSerializer.class,
169      SoapXmlSerializer.class,
170      PlainTextSerializer.class,
171      CsvSerializer.class,
172      YamlSerializer.class,
173      TomlSerializer.class,
174      IniSerializer.class,
175      ParquetSerializer.class,
176      PrototextSerializer.class,
177      MarkdownSerializer.class
178   },
179
180   // Default parsers for all Java methods in the class.
181   parsers={
182      JsonParser.class,
183      Json5Parser.class,
184      Json5lParser.class,
185      JsonlParser.class,
186      XmlParser.class,
187      HtmlParser.class,
188      HjsonParser.class,
189      HoconParser.class,
190      UonParser.class,
191      UrlEncodingParser.class,
192      OpenApiParser.class,
193      BsonParser.class,
194      CborParser.class,
195      MsgPackParser.class,
196      PlainTextParser.class,
197      CsvParser.class,
198      YamlParser.class,
199      TomlParser.class,
200      IniParser.class,
201      ParquetParser.class,
202      PrototextParser.class,
203      MarkdownParser.class
204   },
205
206   // Serializer session properties that clients are allowed to override via HTTP headers/query parameters.
207   allowedSerializerOptions={
208      "useWhitespace",          // WriterSerializer - enable/disable whitespace
209      "maxIndent",              // WriterSerializer - max indentation level
210      "quoteChar",              // WriterSerializer - quote character
211      "keepNullProperties",     // SerializerSession - include null properties
212      "trimStrings",            // SerializerSession - trim string values
213      "addBeanTypes",           // SerializerSession - add bean type annotations
214      "addRootType",            // SerializerSession - add root type annotation
215      "sortCollections",        // SerializerSession - sort collections
216      "sortMaps",               // SerializerSession - sort maps
217      "trimEmptyCollections",   // SerializerSession - trim empty collections
218      "trimEmptyMaps",          // SerializerSession - trim empty maps
219      "binaryFormat",           // OutputStreamSerializer - binary encoding format
220      "escapeSolidus",          // JsonSerializerSession - escape forward slashes
221      "encoding",               // UonSerializerSession - URL-encode characters
222      "paramFormat",            // UonSerializerSession - parameter format style
223      "addNamespaceUrisToRoot", // XmlSerializerSession - add namespace URIs to root
224      "autoDetectNamespaces",   // XmlSerializerSession - auto-detect namespaces
225      "enableNamespaces",       // XmlSerializerSession - enable namespace support
226      "textNodeDelimiter",      // XmlSerializerSession - text node delimiter
227      "addKeyValueTableHeaders",// HtmlSerializerSession - add key/value table headers
228      "detectLabelParameters",  // HtmlSerializerSession - detect label parameters
229      "detectLinksInStrings",   // HtmlSerializerSession - detect links in strings
230      "labelParameter",         // HtmlSerializerSession - label parameter name
231      "uriAnchorText",          // HtmlSerializerSession - URI anchor text strategy
232      "byteArrayFormat",        // CsvSerializerSession - byte array encoding format
233      "allowNestedStructures"   // CsvSerializerSession - allow nested structures
234   },
235
236   // Parser session properties that clients are allowed to override via HTTP headers/query parameters.
237   allowedParserOptions={
238      "trimStrings",            // ParserSession - trim string values
239      "binaryFormat",           // InputStreamParser - binary decoding format
240      "validateEnd",            // JsonParserSession/UonParserSession - validate end of input
241      "decoding",               // UonParserSession - URL-decode characters
242      "expandedParams",         // UrlEncodingParserSession - expanded parameters
243      "preserveRootElement",    // XmlParserSession - preserve root element
244      "validating"              // XmlParserSession - validate XML
245   }
246)
247public interface BasicUniversalConfig extends DefaultConfig, DefaultHtmlConfig {}