http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/package.html b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/package.html new file mode 100644 index 0000000..a70f4ff --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/jsonschema/package.html @@ -0,0 +1,539 @@ +<!DOCTYPE HTML> +<!-- +/*************************************************************************************************************************** + * 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. + * + ***************************************************************************************************************************/ +--> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <style type="text/css"> + /* For viewing in Page Designer */ + @IMPORT url("../../../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + </style> + <script> + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); + } + </script> +</head> +<body> +<p>JSON-Schema Data Transfer Objects</p> +<script> + function toggle(x) { + var div = x.nextSibling; + while (div != null && div.nodeType != 1) + div = div.nextSibling; + if (div != null) { + var d = div.style.display; + if (d == 'block' || d == '') { + div.style.display = 'none'; + x.className += " closed"; + } else { + div.style.display = 'block'; + x.className = x.className.replace(/(?:^|\s)closed(?!\S)/g , '' ); + } + } + } +</script> +<a id='TOC'></a><h5 class='toc'>Table of Contents</h5> +<ol class='toc'> + <li><p><a class='doclink' href='#Overview'>Overview</a></p> + <ol> + <li><p><a class='doclink' href='#SchemaDefinition'>JSON-Schema schema definition</a></p> + <li><p><a class='doclink' href='#Serialize'>Creating JSON-Schema documents</a></p> + <ol> + <li><p><a class='doclink' href='#SerializeToOther'>Serializing to other data types</a></p> + </ol> + <li><p><a class='doclink' href='#Parse'>Parsing JSON-Schema documents</a></p> + </ol> +</ol> +<!-- ======================================================================================================== --> +<a id="Overview"></a> +<h2 class='topic' onclick='toggle(this)'>1 - Overview</h2> +<div class='topic'> + <p> + Juneau supports serializing and parsing of JSON-Schema documents through the use of beans defined in the + <code>org.apache.juneau.dto.jsonschema</code> package. + <br>These beans are used with the existing {@link org.apache.juneau.json.JsonSerializer} and + {@link org.apache.juneau.json.JsonParser} classes to produce and consume JSON-Schema documents. + </p> + <p> + <b>NOTE:</b> JSON-Schema is currently in draft form. + This API may change as the JSON-Schema specification changes. + </p> + + <!-- ======================================================================================================== --> + <a id="SchemaDefinition"></a> + <h3 class='topic' onclick='toggle(this)'>1.1 - JSON-Schema schema definition</h3> + <div class='topic'> + <p> + The draft JSON-Schema specification that the JSON-Schema beans are modeled after is as follows: + </p> + <p class='bcode'> + { + <js>"id"</js>: <js>"http://json-schema.org/draft-04/schema#"</js>, + <js>"$schema"</js>: <js>"http://json-schema.org/draft-04/schema#"</js>, + <js>"description"</js>: <js>"Core schema meta-schema"</js>, + <js>"definitions"</js>: { + <js>"schemaArray"</js>: { + <js>"type"</js>: <js>"array"</js>, + <js>"minItems"</js>: 1, + <js>"items"</js>: { <js>"$ref"</js>: <js>"#"</js> } + }, + <js>"positiveInteger"</js>: { + <js>"type"</js>: <js>"integer"</js>, + <js>"minimum"</js>: 0 + }, + <js>"positiveIntegerDefault0"</js>: { + <js>"allOf"</js>: [ { <js>"$ref"</js>: <js>"#/definitions/positiveInteger"</js> }, + { <js>"default"</js>: 0 } ] + }, + <js>"simpleTypes"</js>: { + <js>"enum"</js>: [ <js>"array"</js>, <js>"boolean"</js>, <js>"integer"</js>, <js>"null"</js>, + <js>"number"</js>, <js>"object"</js>, <js>"string"</js> ] + }, + <js>"stringArray"</js>: { + <js>"type"</js>: <js>"array"</js>, + <js>"items"</js>: { <js>"type"</js>: <js>"string"</js> }, + <js>"minItems"</js>: 1, + <js>"uniqueItems"</js>: <jk>true</jk> + } + }, + <js>"type"</js>: <js>"object"</js>, + <js>"properties"</js>: { + <js>"id"</js>: { + <js>"type"</js>: <js>"string"</js>, + <js>"format"</js>: <js>"uri"</js> + }, + <js>"$schema"</js>: { + <js>"type"</js>: <js>"string"</js>, + <js>"format"</js>: <js>"uri"</js> + }, + <js>"title"</js>: { + <js>"type"</js>: <js>"string"</js> + }, + <js>"description"</js>: { + <js>"type"</js>: <js>"string"</js> + }, + <js>"default"</js>: {}, + <js>"multipleOf"</js>: { + <js>"type"</js>: <js>"number"</js>, + <js>"minimum"</js>: 0, + <js>"exclusiveMinimum"</js>: <jk>true</jk> + }, + <js>"maximum"</js>: { + <js>"type"</js>: <js>"number"</js> + }, + <js>"exclusiveMaximum"</js>: { + <js>"type"</js>: <js>"boolean"</js>, + <js>"default"</js>: <jk>false</jk> + }, + <js>"minimum"</js>: { + <js>"type"</js>: <js>"number"</js> + }, + <js>"exclusiveMinimum"</js>: { + <js>"type"</js>: <js>"boolean"</js>, + <js>"default"</js>: <jk>false</jk> + }, + <js>"maxLength"</js>: { <js>"$ref"</js>: <js>"#/definitions/positiveInteger"</js> }, + <js>"minLength"</js>: { <js>"$ref"</js>: <js>"#/definitions/positiveIntegerDefault0"</js> }, + <js>"pattern"</js>: { + <js>"type"</js>: <js>"string"</js>, + <js>"format"</js>: <js>"regex"</js> + }, + <js>"additionalItems"</js>: { + <js>"anyOf"</js>: [ + { <js>"type"</js>: <js>"boolean"</js> }, + { <js>"$ref"</js>: <js>"#"</js> } + ], + <js>"default"</js>: {} + }, + <js>"items"</js>: { + <js>"anyOf"</js>: [ + { <js>"$ref"</js>: <js>"#"</js> }, + { <js>"$ref"</js>: <js>"#/definitions/schemaArray"</js> } + ], + <js>"default"</js>: {} + }, + <js>"maxItems"</js>: { <js>"$ref"</js>: <js>"#/definitions/positiveInteger"</js> }, + <js>"minItems"</js>: { <js>"$ref"</js>: <js>"#/definitions/positiveIntegerDefault0"</js> }, + <js>"uniqueItems"</js>: { + <js>"type"</js>: <js>"boolean"</js>, + <js>"default"</js>: <jk>false</jk> + }, + <js>"maxProperties"</js>: { <js>"$ref"</js>: <js>"#/definitions/positiveInteger"</js> }, + <js>"minProperties"</js>: { <js>"$ref"</js>: <js>"#/definitions/positiveIntegerDefault0"</js> }, + <js>"required"</js>: { <js>"$ref"</js>: <js>"#/definitions/stringArray"</js> }, + <js>"additionalProperties"</js>: { + <js>"anyOf"</js>: [ + { <js>"type"</js>: <js>"boolean"</js> }, + { <js>"$ref"</js>: <js>"#"</js> } + ], + <js>"default"</js>: {} + }, + <js>"definitions"</js>: { + <js>"type"</js>: <js>"object"</js>, + <js>"additionalProperties"</js>: { <js>"$ref"</js>: <js>"#"</js> }, + <js>"default"</js>: {} + }, + <js>"properties"</js>: { + <js>"type"</js>: <js>"object"</js>, + <js>"additionalProperties"</js>: { <js>"$ref"</js>: <js>"#"</js> }, + <js>"default"</js>: {} + }, + <js>"patternProperties"</js>: { + <js>"type"</js>: <js>"object"</js>, + <js>"additionalProperties"</js>: { <js>"$ref"</js>: <js>"#"</js> }, + <js>"default"</js>: {} + }, + <js>"dependencies"</js>: { + <js>"type"</js>: <js>"object"</js>, + <js>"additionalProperties"</js>: { + <js>"anyOf"</js>: [ + { <js>"$ref"</js>: <js>"#"</js> }, + { <js>"$ref"</js>: <js>"#/definitions/stringArray"</js> } + ] + } + }, + <js>"enum"</js>: { + <js>"type"</js>: <js>"array"</js>, + <js>"minItems"</js>: 1, + <js>"uniqueItems"</js>: <jk>true</jk> + }, + <js>"type"</js>: { + <js>"anyOf"</js>: [ + { <js>"$ref"</js>: <js>"#/definitions/simpleTypes"</js> }, + { + <js>"type"</js>: <js>"array"</js>, + <js>"items"</js>: { <js>"$ref"</js>: <js>"#/definitions/simpleTypes"</js> }, + <js>"minItems"</js>: 1, + <js>"uniqueItems"</js>: <jk>true</jk> + } + ] + }, + <js>"allOf"</js>: { <js>"$ref"</js>: <js>"#/definitions/schemaArray"</js> }, + <js>"anyOf"</js>: { <js>"$ref"</js>: <js>"#/definitions/schemaArray"</js> }, + <js>"oneOf"</js>: { <js>"$ref"</js>: <js>"#/definitions/schemaArray"</js> }, + <js>"not"</js>: { <js>"$ref"</js>: <js>"#"</js> } + }, + <js>"dependencies"</js>: { + <js>"exclusiveMaximum"</js>: [ <js>"maximum"</js> ], + <js>"exclusiveMinimum"</js>: [ <js>"minimum"</js> ] + }, + <js>"default"</js>: {} + } + </p> + <p> + The bean classes that make up the model are as follows: + </p> + <ul class='spaced-list'> + <li> + {@link org.apache.juneau.dto.jsonschema.Schema} - Top level schema object. + <li> + {@link org.apache.juneau.dto.jsonschema.SchemaProperty} - A subclass of <code>Schema</code> for + representing properties. + <li> + {@link org.apache.juneau.dto.jsonschema.SchemaPropertySimpleArray} - A convenience subclass of + <code>SchemaProperty</code> for representing properties of simple array types. + <li> + {@link org.apache.juneau.dto.jsonschema.SchemaRef} - Represents a URI reference to another schema. + <li> + {@link org.apache.juneau.dto.jsonschema.SchemaArray} - An array of <code>Schema</code> objects. + <li> + {@link org.apache.juneau.dto.jsonschema.JsonType} - An enum of possible JSON data types. + <li> + {@link org.apache.juneau.dto.jsonschema.JsonTypeArray} - An array of <code>JsonType</code> objects. + </ul> + </div> + + + <!-- ======================================================================================================== --> + <a id="Serialize"></a> + <h3 class='topic' onclick='toggle(this)'>1.2 - Creating JSON-Schema documents</h3> + <div class='topic'> + <p> + JSON-Schema documents can be constructed using the Juneau JSON-Schema beans as a document model object. + These beans are defined with fluent-style setters to make constructing documents as easy as possible. + </p> + <p> + The following is an example JSON-Schema document: + </p> + <p class='bcode'> + { + <js>"title"</js>: <js>"Example Schema"</js>, + <js>"type"</js>: <js>"object"</js>, + <js>"properties"</js>: { + <js>"firstName"</js>: { + <js>"type"</js>: <js>"string"</js> + }, + <js>"lastName"</js>: { + <js>"type"</js>: <js>"string"</js> + }, + <js>"age"</js>: { + <js>"description"</js>: <js>"Age in years"</js>, + <js>"type"</js>: <js>"integer"</js>, + <js>"minimum"</js>: 0 + } + }, + <js>"required"</js>: [<js>"firstName"</js>, <js>"lastName"</js>] + } + </p> + <p> + This document can be constructing using the following code: + </p> + <p class='bcode'> + <jc>// Create the document object model</jc> + Schema s = <jk>new</jk> Schema() + .setTitle(<js>"Example Schema"</js>) + .setType(JsonType.<jsf>OBJECT</jsf>) + .addProperties( + <jk>new</jk> SchemaProperty(<js>"firstName"</js>, JsonType.<jsf>STRING</jsf>), + <jk>new</jk> SchemaProperty(<js>"lastName"</js>, JsonType.<jsf>STRING</jsf>), + <jk>new</jk> SchemaProperty(<js>"age"</js>, JsonType.<jsf>INTEGER</jsf>) + .setDescription(<js>"Age in years"</js>) + .setMinimum(0) + ) + .addRequired(<js>"firstName"</js>, <js>"lastName"</js>); + + <jc>// Serialize to JSON</jc> + String json = JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(s); + </p> + <p> + The following is a more-complex example showing various kinds of constraints. + </p> + <p class='bcode'> + { + <js>"id"</js>: <js>"http://some.site.somewhere/entry-schema#"</js>, + <js>"$schema"</js>: <js>"http://json-schema.org/draft-04/schema#"</js>, + <js>"description"</js>: <js>"schema for an fstab entry"</js>, + <js>"type"</js>: <js>"object"</js>, + <js>"required"</js>: [ <js>"storage"</js> ], + <js>"properties"</js>: { + <js>"storage"</js>: { + <js>"type"</js>: <js>"object"</js>, + <js>"oneOf"</js>: [ + { <js>"$ref"</js>: <js>"#/definitions/diskDevice"</js> }, + { <js>"$ref"</js>: <js>"#/definitions/diskUUID"</js> }, + { <js>"$ref"</js>: <js>"#/definitions/nfs"</js> }, + { <js>"$ref"</js>: <js>"#/definitions/tmpfs"</js> } + ] + }, + <js>"fstype"</js>: { + <js>"enum"</js>: [ <js>"ext3"</js>, <js>"ext4"</js>, <js>"btrfs"</js> ] + }, + <js>"options"</js>: { + <js>"type"</js>: <js>"array"</js>, + <js>"minItems"</js>: 1, + <js>"items"</js>: { <js>"type"</js>: <js>"string"</js> }, + <js>"uniqueItems"</js>: <jk>true</jk> + }, + <js>"readonly"</js>: { <js>"type"</js>: <js>"boolean"</js> } + }, + <js>"definitions"</js>: { + <js>"diskDevice"</js>: {}, + <js>"diskUUID"</js>: {}, + <js>"nfs"</js>: {}, + <js>"tmpfs"</js>: {} + } + } + </p> + <p> + This document can be constructing using the following code: + </p> + <p class='bcode'> + Schema s = <jk>new</jk> Schema() + .setId(<js>"http://some.site.somewhere/entry-schema#"</js>) + .setSchemaVersionId(<js>"http://json-schema.org/draft-04/schema#"</js>) + .setDescription(<js>"schema for an fstab entry"</js>) + .setType(JsonType.<jsf>OBJECT</jsf>) + .addRequired(<js>"storage"</js>) + .addProperties( + <jk>new</jk> SchemaProperty(<js>"storage"</js>) + .setType(JsonType.<jsf>OBJECT</jsf>) + .addOneOf( + <jk>new</jk> SchemaRef(<js>"#/definitions/diskDevice"</js>), + <jk>new</jk> SchemaRef(<js>"#/definitions/diskUUID"</js>), + <jk>new</jk> SchemaRef(<js>"#/definitions/nsf"</js>), + <jk>new</jk> SchemaRef(<js>"#/definitions/tmpfs"</js>) + ), + <jk>new</jk> SchemaProperty(<js>"fstype"</js>) + .addEnum(<js>"ext3"</js>, <js>"ext4"</js>, <js>"btrfs"</js>), + <jk>new</jk> SchemaPropertySimpleArray(<js>"options"</js>, JsonType.<jsf>STRING</jsf>) + .setMinItems(1) + .setUniqueItems(<jk>true</jk>), + <jk>new</jk> SchemaProperty(<js>"readonly"</js>) + .setType(JsonType.<jsf>BOOLEAN</jsf>) + ) + .addDefinition(<js>"diskDevice"</js>, + <jk>new</jk> Schema() + ) + .addDefinition(<js>"diskUUID"</js>, + <jk>new</jk> Schema() + ) + .addDefinition(<js>"nfs"</js>, + <jk>new</jk> Schema() + ) + .addDefinition(<js>"tmpfs"</js>, + <jk>new</jk> Schema() + ); + + <jc>// Serialize to JSON</jc> + String json = JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(s); + </p> + + + <!-- ======================================================================================================== --> + <a id="SerializeToOther"></a> + <h4 class='topic' onclick='toggle(this)'>1.2.1 - Serializing to other data types</h4> + <div class='topic'> + <p> + Since the JSON-Schema DTOs are simple beans, they can be used to serialize to a variety of other + language types as well as JSON. + This also allows JSON-Schema documents to be easily served up using the Juneau REST API. + </p> + <p> + The sample web application includes a REST resource that generates a JSON-Schema document. + We'll use this resource to show what the JSON-Schema document looks like in other languages. + </p> + <p class='bcode'> + <jd>/** + * Sample resource that shows how to serialize JSON-Schema documents. + */</jd> + <ja>@RestResource</ja>( + path=<js>"/jsonSchema"</js>, + messages=<js>"nls/JsonSchemaResource"</js>, + title=<js>"Sample JSON-Schema document"</js>, + htmldoc=<ja>@HtmlDoc</ja>( + links={ + <js>"options: ?method=OPTIONS"</js> + } + ) + ) + <jk>public class</jk> JsonSchemaResource <jk>extends</jk> RestServletJenaDefault { + + <jk>private</jk> Schema <jf>schema</jf>; <jc>// The schema document</jc> + + <jd>/** Servlet initialization */</jd> + <ja>@Override</ja> + <jk>public void</jk> init() { + + <jk>try</jk> { + <jf>schema</jf> = <jk>new</jk> Schema() + .setId(<js>"http://example.com/sample-schema#"</js>) + .setSchemaVersionUri(<js>"http://json-schema.org/draft-04/schema#"</js>) + .setTitle(<js>"Example Schema"</js>) + .setType(JsonType.<jsf>OBJECT</jsf>) + .addProperties( + <jk>new</jk> SchemaProperty(<js>"firstName"</js>, JsonType.<jsf>STRING</jsf>), + <jk>new</jk> SchemaProperty(<js>"lastName"</js>, JsonType.<jsf>STRING</jsf>), + <jk>new</jk> SchemaProperty(<js>"age"</js>, JsonType.<jsf>INTEGER</jsf>) + .setDescription(<js>"Age in years"</js>) + .setMinimum(0) + ) + .addRequired(<js>"firstName"</js>, <js>"lastName"</js>); + } <jk>catch</jk> (Exception e) { + <jk>throw new</jk> RuntimeException(e); + } + } + + <jd>/** GET request handler */</jd> + <ja>@RestMethod</ja>(name=<js>"GET"</js>, path=<js>"/"</js>) + <jk>public</jk> Schema getSchema() <jk>throws</jk> Exception { + <jk>return</jk> <jf>schema</jf>; + } + + <jd>/** + * PUT request handler. + * Replaces the schema document with the specified content, and then mirrors it as the response. + */</jd> + <ja>@RestMethod</ja>(name=<js>"PUT"</js>, path=<js>"/"</js>) + <jk>public</jk> Schema setSchema(<ja>@Body</ja> Schema schema) <jk>throws</jk> Exception { + <jk>this</jk>.<jf>schema</jf> = schema; + <jk>return</jk> <jk>this</jk>.<jf>schema</jf>; + } + + <jd>/** OPTIONS request handler */</jd> + <ja>@RestMethod</ja>(name=<js>"OPTIONS"</js>, path=<js>"/*"</js>) + <jk>public</jk> ResourceOptions doOptions(RestRequest req) { + <jk>return new</jk> ResourceOptions(<jk>this</jk>, req); + } + } + </p> + <p> + When you point your browser to this resource, the default content type is HTML (since that's what the + browser asks for by default). + </p> + + <h6 class='figure'>HTML</h6> + <img class='bordered' src="doc-files/Example_Html.png"> + <p> + The REST API allows you to specify the <code>Accept</code> header as a GET parameter, and the + <code>plainText=true</code> parameter forces the returned <code>Content-Type</code> to be + <code>text/plain</code>. + We'll use this to view the JSON-Schema document in other languages. + </p> + + <h6 class='figure'>Normal JSON</h6> + <img class='bordered' src="doc-files/Example_Json.png"> + + <h6 class='figure'>XML</h6> + <img class='bordered' src="doc-files/Example_Xml.png"> + + <h6 class='figure'>URL-Encoded</h6> + <img class='bordered' src="doc-files/Example_UrlEncoded.png"> + + <h6 class='figure'>Abbreviated RDF/XML</h6> + <img class='bordered' src="doc-files/Example_XmlRdfAbbrev.png"> + + <h6 class='figure'>Turtle</h6> + <img class='bordered' src="doc-files/Example_Turtle.png"> + + <p> + The full list of options for this resource can be accessed by the <code>options</code> link on the HTML + page. + </p> + + <h6 class='figure'>Resource Options</h6> + <img class='bordered' src="doc-files/Example_Options.png"> + </div> + </div> + + <!-- ======================================================================================================== --> + <a id="Parse"></a> + <h3 class='topic' onclick='toggle(this)'>1.3 - Parsing JSON-Schema documents</h3> + <div class='topic'> + <p> + Use the {@link org.apache.juneau.json.JsonParser} to parse JSON-Schema documents into DTOs: + </p> + <p class='bcode'> + <jc>// Use parser to load JSON-Schema document into JSON-Schema DTOs</jc> + Schema schema = JsonParser.<jsf>DEFAULT</jsf>.parse(json, Schema.<jk>class</jk>); + </p> + <p> + Schema objects can also be constructed from the other media types using the appropriate parsers. + </p> + </div> + +</div> +<p align="center"><i><b>*** fÃn ***</b></i></p> +</body> +</html> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/package.html b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/package.html new file mode 100644 index 0000000..4574810 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/package.html @@ -0,0 +1,41 @@ +<!DOCTYPE HTML> +<!-- +/*************************************************************************************************************************** + * 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. + * + ***************************************************************************************************************************/ + --> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <style type="text/css"> + /* For viewing in Page Designer */ + @IMPORT url("../../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + </style> + <script> + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); + } + </script> +</head> +<body> +<p>Data transfer objects</p> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java new file mode 100644 index 0000000..b08e4ba --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Contact.java @@ -0,0 +1,169 @@ +// *************************************************************************************************************************** +// * 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.dto.swagger; + +import static org.apache.juneau.internal.StringUtils.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; + +/** + * Contact information for the exposed API. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"name"</js>: <js>"API Support"</js>, + * <js>"url"</js>: <js>"http://www.swagger.io/support"</js>, + * <js>"email"</js>: <js>"[email protected]"</js> + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Swagger'>Swagger</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.swagger</a> + * </li> + * </ul> + */ +@Bean(properties="name,url,email") +@SuppressWarnings("hiding") +public class Contact extends SwaggerElement { + + private String name; + private URI url; + private String email; + + /** + * Bean property getter: <property>name</property>. + * + * <p> + * The identifying name of the contact person/organization. + * + * @return The value of the <property>name</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getName() { + return name; + } + + /** + * Bean property setter: <property>name</property>. + * + * <p> + * The identifying name of the contact person/organization. + * + * @param name The new value for the <property>name</property> property on this bean. + * @return This object (for method chaining). + */ + public Contact setName(String name) { + this.name = name; + return this; + } + + /** + * Synonym for {@link #setName(String)}. + * + * @param name The new value for the <property>name</property> property on this bean. + * @return This object (for method chaining). + */ + public Contact name(String name) { + return setName(name); + } + + /** + * Bean property getter: <property>url</property>. + * + * <p> + * The URL pointing to the contact information. MUST be in the format of a URL. + * + * @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public URI getUrl() { + return url; + } + + /** + * Bean property setter: <property>url</property>. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param url The new value for the <property>url</property> property on this bean. + * @return This object (for method chaining). + */ + public Contact setUrl(Object url) { + this.url = toURI(url); + return this; + } + + /** + * Synonym for {@link #setUrl(Object)}. + * + * @param url The new value for the <property>url</property> property on this bean. + * @return This object (for method chaining). + */ + public Contact url(Object url) { + return setUrl(url); + } + + /** + * Bean property getter: <property>email</property>. + * + * <p> + * The email address of the contact person/organization. MUST be in the format of an email address. + * + * @return The value of the <property>email</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getEmail() { + return email; + } + + /** + * Bean property setter: <property>email</property>. + * + * <p> + * The email address of the contact person/organization. MUST be in the format of an email address. + * + * @param email The new value for the <property>email</property> property on this bean. + * @return This object (for method chaining). + */ + public Contact setEmail(String email) { + this.email = email; + return this; + } + + /** + * Synonym for {@link #setEmail(String)}. + * + * @param email The new value for the <property>email</property> property on this bean. + * @return This object (for method chaining). + */ + public Contact email(String email) { + return setEmail(email); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java new file mode 100644 index 0000000..e1485e9 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ExternalDocumentation.java @@ -0,0 +1,139 @@ +// *************************************************************************************************************************** +// * 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.dto.swagger; + +import static org.apache.juneau.internal.StringUtils.*; + +import java.net.*; +import java.net.URI; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; + +/** + * Allows referencing an external resource for extended documentation. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"description"</js>: <js>"Find more info here"</js>, + * <js>"url"</js>: <js>"https://swagger.io"</js> + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Swagger'>Swagger</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.swagger</a> + * </li> + * </ul> + */ +@Bean(properties="description,url") +@SuppressWarnings("hiding") +public class ExternalDocumentation extends SwaggerElement { + + private String description; + private URI url; + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * A short description of the target documentation. GFM syntax can be used for rich text representation. + * + * @return + * The value of the <property>description</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getDescription() { + return description; + } + + /** + * Bean property setter: <property>description</property>. + * + * <p> + * A short description of the target documentation. GFM syntax can be used for rich text representation. + * + * @param description The new value for the <property>description</property> property on this bean. + * @return This object (for method chaining). + */ + public ExternalDocumentation setDescription(String description) { + this.description = description; + return this; + } + + /** + * Synonym for {@link #setDescription(String)}. + * + * @param description The new value for the <property>description</property> property on this bean. + * @return This object (for method chaining). + */ + public ExternalDocumentation description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>url</property>. + * + * <p> + * Required. The URL for the target documentation. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @return The value of the <property>url</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public URI getUrl() { + return url; + } + + /** + * Bean property setter: <property>url</property>. + * + * <p> + * The value can be of any of the following types: {@link URI}, {@link URL}, {@link String}. + * Strings must be valid URIs. + * + * <p> + * URIs defined by {@link UriResolver} can be used for values. + * + * @param url The new value for the <property>url</property> property on this bean. + * @return This object (for method chaining). + */ + public ExternalDocumentation setUrl(Object url) { + this.url = toURI(url); + return this; + } + + /** + * Synonym for {@link #setUrl(Object)}. + * + * @param url The new value for the <property>url</property> property on this bean. + * @return This object (for method chaining). + */ + public ExternalDocumentation url(Object url) { + return setUrl(url); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java new file mode 100644 index 0000000..1978253 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/HeaderInfo.java @@ -0,0 +1,832 @@ +// *************************************************************************************************************************** +// * 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.dto.swagger; + +import static org.apache.juneau.internal.ArrayUtils.*; + +import java.util.*; + +import org.apache.juneau.*; +import org.apache.juneau.annotation.*; + +/** + * Describes a single HTTP header. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"description"</js>: <js>"The number of allowed requests in the current period"</js>, + * <js>"type"</js>: <js>"integer"</js> + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Swagger'>Swagger</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.swagger</a> + * </li> + * </ul> + */ +@Bean(properties="description,type,format,items,collectionFormat,default,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,enum,multipleOf") +@SuppressWarnings({"hiding", "unchecked"}) +public class HeaderInfo extends SwaggerElement { + + private static final String[] VALID_TYPES = {"string", "number", "integer", "boolean", "array"}; + private static final String[] VALID_COLLECTION_FORMATS = {"csv","ssv","tsv","pipes","multi"}; + + private String description; + private String type; + private String format; + private Items items; + private String collectionFormat; + private Object _default; + private Number maximum; + private Boolean exclusiveMaximum; + private Number minimum; + private Boolean exclusiveMinimum; + private Integer maxLength; + private Integer minLength; + private String pattern; + private Integer maxItems; + private Integer minItems; + private Boolean uniqueItems; + private List<Object> _enum; + private Number multipleOf; + + @Override /* SwaggerElement */ + protected HeaderInfo strict() { + super.strict(); + return this; + } + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * A short description of the header. + * + * @return + * The value of the <property>description</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getDescription() { + return description; + } + + /** + * Bean property setter: <property>description</property>. + * + * <p> + * A short description of the header. + * + * @param description The new value for the <property>description</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setDescription(String description) { + this.description = description; + return this; + } + + /** + * Synonym for {@link #description(String)}. + * + * @param description The new value for the <property>description</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>type</property>. + * + * <p> + * Required. The type of the object. + * The value MUST be one of <js>"string"</js>, <js>"number"</js>, <js>"integer"</js>, <js>"boolean"</js>, or < + * js>"array"</js>. + * + * @return The value of the <property>type</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getType() { + return type; + } + + /** + * Bean property setter: <property>type</property>. + * + * <p> + * Required. The type of the object. + * The value MUST be one of <js>"string"</js>, <js>"number"</js>, <js>"integer"</js>, <js>"boolean"</js>, or + * <js>"array"</js>. + * + * @param type The new value for the <property>type</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setType(String type) { + if (isStrict() && ! contains(type, VALID_TYPES)) + throw new FormattedRuntimeException( + "Invalid value passed in to setType(String). Value=''{0}'', valid values={1}", + type, VALID_TYPES + ); + this.type = type; + return this; + } + + /** + * Synonym for {@link #setType(String)}. + * + * @param type The new value for the <property>type</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo type(String type) { + return setType(type); + } + + /** + * Bean property getter: <property>format</property>. + * + * <p> + * The extending format for the previously mentioned <code>type</code>. + * See <a class="doclink" href="http://swagger.io/specification/#dataTypeFormat">Data Type Formats</a> for further + * details. + * + * @return The value of the <property>format</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getFormat() { + return format; + } + + /** + * Bean property setter: <property>format</property>. + * + * <p> + * The extending format for the previously mentioned <code>type</code>. + * See <a class="doclink" href="http://swagger.io/specification/#dataTypeFormat">Data Type Formats</a> for further + * details. + * + * @param format The new value for the <property>format</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setFormat(String format) { + this.format = format; + return this; + } + + /** + * Synonym for {@link #setFormat(String)}. + * + * @param format The new value for the <property>format</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo format(String format) { + return setFormat(format); + } + + /** + * Bean property getter: <property>items</property>. + * + * <p> + * Required if <code>type</code> is <js>"array"</js>. + * Describes the type of items in the array. + * + * @return The value of the <property>items</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Items getItems() { + return items; + } + + /** + * Bean property setter: <property>items</property>. + * + * <p> + * Required if <code>type</code> is <js>"array"</js>. + * Describes the type of items in the array. + * + * @param items The new value for the <property>items</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setItems(Items items) { + this.items = items; + return this; + } + + /** + * Synonym for {@link #setItems(Items)}. + * + * @param items The new value for the <property>items</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo items(Items items) { + return setItems(items); + } + + /** + * Bean property getter: <property>collectionFormat</property>. + * + * <p> + * Determines the format of the array if type array is used. + * <p> + * + * Possible values are: + * <ul> + * <li><code>csv</code> - comma separated values <code>foo,bar</code>. + * <li><code>ssv</code> - space separated values <code>foo bar</code>. + * <li><code>tsv</code> - tab separated values <code>foo\tbar</code>. + * <li><code>pipes</code> - pipe separated values <code>foo|bar</code>. + * </ul> + * + * <p> + * Default value is <code>csv</code>. + * + * @return + * The value of the <property>collectionFormat</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getCollectionFormat() { + return collectionFormat; + } + + /** + * Bean property setter: <property>collectionFormat</property>. + * + * <p> + * Determines the format of the array if type array is used. + * + * <p> + * Possible values are: + * <ul> + * <li><code>csv</code> - comma separated values <code>foo,bar</code>. + * <li><code>ssv</code> - space separated values <code>foo bar</code>. + * <li><code>tsv</code> - tab separated values <code>foo\tbar</code>. + * <li><code>pipes</code> - pipe separated values <code>foo|bar</code>. + * </ul> + * + * <p> + * Default value is <code>csv</code>. + * + * @param collectionFormat The new value for the <property>collectionFormat</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setCollectionFormat(String collectionFormat) { + if (isStrict() && ! contains(collectionFormat, VALID_COLLECTION_FORMATS)) + throw new FormattedRuntimeException( + "Invalid value passed in to setCollectionFormat(String). Value=''{0}'', valid values={1}", + collectionFormat, VALID_COLLECTION_FORMATS + ); + this.collectionFormat = collectionFormat; + return this; + } + + /** + * Synonym for {@link #setCollectionFormat(String)}. + * + * @param collectionFormat The new value for the <property>collectionFormat</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo collectionFormat(String collectionFormat) { + return setCollectionFormat(collectionFormat); + } + + /** + * Bean property getter: <property>default</property>. + * + * <p> + * Declares the value of the header that the server will use if none is provided. + * (Note: <js>"default"</js> has no meaning for required items.) + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor101"> + * http://json-schema.org/latest/json-schema-validation.html#anchor101</a>. + * Unlike JSON Schema this value MUST conform to the defined <code>type</code> for the header. + * + * @return The value of the <property>_default</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Object getDefault() { + return _default; + } + + /** + * Bean property setter: <property>default</property>. + * + * <p> + * Declares the value of the header that the server will use if none is provided. + * (Note: <js>"default"</js> has no meaning for required items.) + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor101"> + * http://json-schema.org/latest/json-schema-validation.html#anchor101</a>. + * Unlike JSON Schema this value MUST conform to the defined <code>type</code> for the header. + * + * @param _default The new value for the <property>_default</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setDefault(Object _default) { + this._default = _default; + return this; + } + + /** + * Synonym for {@link #setDefault(Object)}. + * + * @param _default The new value for the <property>_default</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo _default(Object _default) { + return setDefault(_default); + } + + /** + * Bean property getter: <property>maximum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17"> + * http://json-schema.org/latest/json-schema-validation.html#anchor17</a>. + * + * @return The value of the <property>maximum</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Number getMaximum() { + return maximum; + } + + /** + * Bean property setter: <property>maximum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17"> + * http://json-schema.org/latest/json-schema-validation.html#anchor17</a>. + * + * @param maximum The new value for the <property>maximum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMaximum(Number maximum) { + this.maximum = maximum; + return this; + } + + /** + * Synonym for {@link #setMaximum(Number)}. + * + * @param maximum The new value for the <property>maximum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo maximum(Number maximum) { + return setMaximum(maximum); + } + + /** + * Bean property getter: <property>exclusiveMaximum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17"> + * http://json-schema.org/latest/json-schema-validation.html#anchor17</a>. + * + * @return The value of the <property>exclusiveMaximum</property> property on this bean, or <jk>null</jk> if it is + * not set. + */ + public Boolean getExclusiveMaximum() { + return exclusiveMaximum; + } + + /** + * Bean property setter: <property>exclusiveMaximum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor17"> + * http://json-schema.org/latest/json-schema-validation.html#anchor17</a>. + * + * @param exclusiveMaximum The new value for the <property>exclusiveMaximum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setExclusiveMaximum(Boolean exclusiveMaximum) { + this.exclusiveMaximum = exclusiveMaximum; + return this; + } + + /** + * Synonym for {@link #setExclusiveMaximum(Boolean)}. + * + * @param exclusiveMaximum The new value for the <property>exclusiveMaximum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo exclusiveMaximum(Boolean exclusiveMaximum) { + return setExclusiveMaximum(exclusiveMaximum); + } + + /** + * Bean property getter: <property>minimum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21"> + * http://json-schema.org/latest/json-schema-validation.html#anchor21</a>. + * + * @return The value of the <property>minimum</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Number getMinimum() { + return minimum; + } + + /** + * Bean property setter: <property>minimum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21"> + * http://json-schema.org/latest/json-schema-validation.html#anchor21</a>. + * + * @param minimum The new value for the <property>minimum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMinimum(Number minimum) { + this.minimum = minimum; + return this; + } + + /** + * Synonym for {@link #setMinimum(Number)}. + * + * @param minimum The new value for the <property>minimum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo minimum(Number minimum) { + return setMinimum(minimum); + } + + /** + * Bean property getter: <property>exclusiveMinimum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21"> + * http://json-schema.org/latest/json-schema-validation.html#anchor21</a>. + * + * @return The value of the <property>exclusiveMinimum</property> property on this bean, or <jk>null</jk> if it is + * not set. + */ + public Boolean getExclusiveMinimum() { + return exclusiveMinimum; + } + + /** + * Bean property setter: <property>exclusiveMinimum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor21"> + * http://json-schema.org/latest/json-schema-validation.html#anchor21</a>. + * + * @param exclusiveMinimum The new value for the <property>exclusiveMinimum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setExclusiveMinimum(Boolean exclusiveMinimum) { + this.exclusiveMinimum = exclusiveMinimum; + return this; + } + + /** + * Synonym for {@link #setExclusiveMinimum(Boolean)}. + * + * @param exclusiveMinimum The new value for the <property>exclusiveMinimum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo exclusiveMinimum(Boolean exclusiveMinimum) { + return setExclusiveMinimum(exclusiveMinimum); + } + + /** + * Bean property getter: <property>maxLength</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor26"> + * http://json-schema.org/latest/json-schema-validation.html#anchor26</a>. + * + * @return The value of the <property>maxLength</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Integer getMaxLength() { + return maxLength; + } + + /** + * Bean property setter: <property>maxLength</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor26"> + * http://json-schema.org/latest/json-schema-validation.html#anchor26</a>. + * + * @param maxLength The new value for the <property>maxLength</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMaxLength(Integer maxLength) { + this.maxLength = maxLength; + return this; + } + + /** + * Synonym for {@link #setMaxLength(Integer)}. + * + * @param maxLength The new value for the <property>maxLength</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo maxLength(Integer maxLength) { + return setMaxLength(maxLength); + } + + /** + * Bean property getter: <property>minLength</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor29"> + * http://json-schema.org/latest/json-schema-validation.html#anchor29</a>. + * + * @return The value of the <property>minLength</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Integer getMinLength() { + return minLength; + } + + /** + * Bean property setter: <property>minLength</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor29"> + * http://json-schema.org/latest/json-schema-validation.html#anchor29</a>. + * + * @param minLength The new value for the <property>minLength</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMinLength(Integer minLength) { + this.minLength = minLength; + return this; + } + + /** + * @param minLength The new value for the <property>minLength</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo minLength(Integer minLength) { + return setMinLength(minLength); + } + + /** + * Bean property getter: <property>pattern</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor33"> + * http://json-schema.org/latest/json-schema-validation.html#anchor33</a>. + * + * @return The value of the <property>pattern</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getPattern() { + return pattern; + } + + /** + * Bean property setter: <property>pattern</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor33"> + * http://json-schema.org/latest/json-schema-validation.html#anchor33</a>. + * + * @param pattern The new value for the <property>pattern</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setPattern(String pattern) { + this.pattern = pattern; + return this; + } + + /** + * Synonym for {@link #setPattern(String)}. + * + * @param pattern The new value for the <property>pattern</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo pattern(String pattern) { + return setPattern(pattern); + } + + /** + * Bean property getter: <property>maxItems</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor42"> + * http://json-schema.org/latest/json-schema-validation.html#anchor42</a>. + * + * @return The value of the <property>maxItems</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Integer getMaxItems() { + return maxItems; + } + + /** + * Bean property setter: <property>maxItems</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor42"> + * http://json-schema.org/latest/json-schema-validation.html#anchor42</a>. + * + * @param maxItems The new value for the <property>maxItems</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMaxItems(Integer maxItems) { + this.maxItems = maxItems; + return this; + } + + /** + * Synonym for {@link #setMaxItems(Integer)}. + * + * @param maxItems The new value for the <property>maxItems</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo maxItems(Integer maxItems) { + return setMaxItems(maxItems); + } + + /** + * Bean property getter: <property>minItems</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor45"> + * http://json-schema.org/latest/json-schema-validation.html#anchor45</a>. + * + * @return The value of the <property>minItems</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Integer getMinItems() { + return minItems; + } + + /** + * Bean property setter: <property>minItems</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor45"> + * http://json-schema.org/latest/json-schema-validation.html#anchor45</a>. + * + * @param minItems The new value for the <property>minItems</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMinItems(Integer minItems) { + this.minItems = minItems; + return this; + } + + /** + * Synonym for {@link #setMinItems(Integer)}. + * + * @param minItems The new value for the <property>minItems</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo minItems(Integer minItems) { + return setMinItems(minItems); + } + + /** + * Bean property getter: <property>uniqueItems</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor49"> + * http://json-schema.org/latest/json-schema-validation.html#anchor49</a>. + * + * @return The value of the <property>uniqueItems</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Boolean getUniqueItems() { + return uniqueItems; + } + + /** + * Bean property setter: <property>uniqueItems</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor49"> + * http://json-schema.org/latest/json-schema-validation.html#anchor49</a>. + * + * @param uniqueItems The new value for the <property>uniqueItems</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setUniqueItems(Boolean uniqueItems) { + this.uniqueItems = uniqueItems; + return this; + } + + /** + * Synonym for {@link #setUniqueItems(Boolean)}. + * + * @param uniqueItems The new value for the <property>uniqueItems</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo uniqueItems(Boolean uniqueItems) { + return setUniqueItems(uniqueItems); + } + + /** + * Bean property getter: <property>enum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor76"> + * http://json-schema.org/latest/json-schema-validation.html#anchor76</a>. + * + * @return The value of the <property>enum</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<Object> getEnum() { + return _enum; + } + + /** + * Bean property setter: <property>enum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor76"> + * http://json-schema.org/latest/json-schema-validation.html#anchor76</a>. + * + * @param _enum The new value for the <property>enum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setEnum(List<Object> _enum) { + this._enum = _enum; + return this; + } + + /** + * Bean property adder: <property>enum</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor76"> + * http://json-schema.org/latest/json-schema-validation.html#anchor76</a>. + * + * @param _enum + * The new values to add to the <property>enum</property> property on this bean. + * These can either be individual objects or {@link Collection Collections} of objects. + * @return This object (for method chaining). + */ + public HeaderInfo addEnum(Object..._enum) { + for (Object o : _enum) { + if (o != null) { + if (o instanceof Collection) + addEnum((Collection<Object>)o); + else { + if (this._enum == null) + this._enum = new LinkedList<Object>(); + this._enum.add(o); + } + } + } + return this; + } + + /** + * Synonym for {@link #addEnum(Object...)}. + * + * @param _enum The new value for the <property>enum</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo _enum(Object..._enum) { + return addEnum(_enum); + } + + /** + * Bean property getter: <property>multipleOf</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor14"> + * http://json-schema.org/latest/json-schema-validation.html#anchor14</a>. + * + * @return The value of the <property>multipleOf</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Number getMultipleOf() { + return multipleOf; + } + + /** + * Bean property setter: <property>multipleOf</property>. + * + * <p> + * See <a class="doclink" href="http://json-schema.org/latest/json-schema-validation.html#anchor14"> + * http://json-schema.org/latest/json-schema-validation.html#anchor14</a>. + * + * @param multipleOf The new value for the <property>multipleOf</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo setMultipleOf(Number multipleOf) { + this.multipleOf = multipleOf; + return this; + } + + /** + * Synonym for {@link #setMultipleOf(Number)}. + * + * @param multipleOf The new value for the <property>multipleOf</property> property on this bean. + * @return This object (for method chaining). + */ + public HeaderInfo multipleOf(Number multipleOf) { + return setMultipleOf(multipleOf); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java new file mode 100644 index 0000000..d31d8b6 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Info.java @@ -0,0 +1,283 @@ +// *************************************************************************************************************************** +// * 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.dto.swagger; + +import org.apache.juneau.annotation.*; + +/** + * The object provides metadata about the API. The metadata can be used by the clients if needed, and can be presented + * in the Swagger-UI for convenience. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"title"</js>: <js>"Swagger Sample App"</js>, + * <js>"description"</js>: <js>"This is a sample server Petstore server."</js>, + * <js>"termsOfService"</js>: <js>"http://swagger.io/terms/"</js>, + * <js>"contact"</js>: { + * <js>"name"</js>: <js>"API Support"</js>, + * <js>"url"</js>: <js>"http://www.swagger.io/support"</js>, + * <js>"email"</js>: <js>"[email protected]"</js> + * }, + * <js>"license"</js>: { + * <js>"name"</js>: <js>"Apache 2.0"</js>, + * <js>"url"</js>: <js>"http://www.apache.org/licenses/LICENSE-2.0.html"</js> + * }, + * <js>"version"</js>: <js>"1.0.1"</js> + * } + * </p> + * + * <h6 class='topic'>Additional Information</h6> + * <ul class='doctree'> + * <li class='link'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs'>Juneau Data Transfer Objects + * (org.apache.juneau.dto)</a> + * <ul> + * <li class='sublink'> + * <a class='doclink' href='../../../../../overview-summary.html#DTOs.Swagger'>Swagger</a> + * </ul> + * </li> + * <li class='jp'> + * <a class='doclink' href='package-summary.html#TOC'>org.apache.juneau.dto.swagger</a> + * </li> + * </ul> + */ +@Bean(properties="title,description,termsOfService,contact,license,version") +@SuppressWarnings("hiding") +public class Info extends SwaggerElement { + + private String title; + private String description; + private String termsOfService; + private Contact contact; + private License license; + private String version; + + /** + * Bean property getter: <property>title</property>. + * + * <p> + * Required. The title of the application. + * + * @return The value of the <property>title</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getTitle() { + return title; + } + + /** + * Bean property setter: <property>title</property>. + * + * <p> + * Required. The title of the application. + * + * @param title The new value for the <property>title</property> property on this bean. + * @return This object (for method chaining). + */ + public Info setTitle(String title) { + this.title = title; + return this; + } + + /** + * Synonym for {@link #setTitle(String)}. + * + * @param title The new value for the <property>title</property> property on this bean. + * @return This object (for method chaining). + */ + public Info title(String title) { + return setTitle(title); + } + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * A short description of the application. GFM syntax can be used for rich text representation. + * + * @return + * The value of the <property>description</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getDescription() { + return description; + } + + /** + * Bean property setter: <property>description</property>. + * + * <p> + * A short description of the application. GFM syntax can be used for rich text representation. + * + * @param description The new value for the <property>description</property> property on this bean. + * @return This object (for method chaining). + */ + public Info setDescription(String description) { + this.description = description; + return this; + } + + /** + * Synonym for {@link #setDescription(String)}. + * + * @param description The new value for the <property>description</property> property on this bean. + * @return This object (for method chaining). + */ + public Info description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>termsOfService</property>. + * + * <p> + * The Terms of Service for the API. + * + * @return The value of the <property>termsOfService</property> property on this bean, or <jk>null</jk> if it is not + * set. + */ + public String getTermsOfService() { + return termsOfService; + } + + /** + * Bean property setter: <property>termsOfService</property>. + * + * <p> + * The Terms of Service for the API. + * + * @param termsOfService The new value for the <property>termsOfService</property> property on this bean. + * @return This object (for method chaining). + */ + public Info setTermsOfService(String termsOfService) { + this.termsOfService = termsOfService; + return this; + } + + /** + * Synonym for {@link #setTermsOfService(String)}. + * + * @param termsOfService The new value for the <property>termsOfService</property> property on this bean. + * @return This object (for method chaining). + */ + public Info termsOfService(String termsOfService) { + return setTermsOfService(termsOfService); + } + + /** + * Bean property getter: <property>contact</property>. + * + * <p> + * The contact information for the exposed API. + * + * @return The value of the <property>contact</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Contact getContact() { + return contact; + } + + /** + * Bean property setter: <property>contact</property>. + * + * <p> + * The contact information for the exposed API. + * + * @param contact The new value for the <property>contact</property> property on this bean. + * @return This object (for method chaining). + */ + public Info setContact(Contact contact) { + this.contact = contact; + return this; + } + + /** + * Synonym for {@link #setContact(Contact)}. + * + * @param contact The new value for the <property>contact</property> property on this bean. + * @return This object (for method chaining). + */ + public Info contact(Contact contact) { + return setContact(contact); + } + + /** + * Bean property getter: <property>license</property>. + * + * <p> + * The license information for the exposed API. + * + * @return The value of the <property>license</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public License getLicense() { + return license; + } + + /** + * Bean property setter: <property>license</property>. + * + * <p> + * The license information for the exposed API. + * + * @param license The new value for the <property>license</property> property on this bean. + * @return This object (for method chaining). + */ + public Info setLicense(License license) { + this.license = license; + return this; + } + + /** + * Synonym for {@link #setLicense(License)}. + * + * @param license The new value for the <property>license</property> property on this bean. + * @return This object (for method chaining). + */ + public Info license(License license) { + return setLicense(license); + } + + /** + * Bean property getter: <property>version</property>. + * + * <p> + * Required. Provides the version of the application API (not to be confused with the specification version). + * + * @return The value of the <property>version</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getVersion() { + return version; + } + + /** + * Bean property setter: <property>version</property>. + * + * <p> + * Required. Provides the version of the application API (not to be confused with the specification version). + * + * @param version The new value for the <property>version</property> property on this bean. + * @return This object (for method chaining). + */ + public Info setVersion(String version) { + this.version = version; + return this; + } + + /** + * Synonym for {@link #setVersion(String)}. + * + * @param version The new value for the <property>version</property> property on this bean. + * @return This object (for method chaining). + */ + public Info version(String version) { + return setVersion(version); + } +}
