http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java new file mode 100644 index 0000000..d9e9d53 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ParameterInfo.java @@ -0,0 +1,1149 @@ +// *************************************************************************************************************************** +// * 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 operation parameter. + * + * <p> + * A unique parameter is defined by a combination of a name and location. + * + * <p> + * There are five possible parameter types. + * <ul> + * <li><js>"path"</js> - Used together with Path Templating, where the parameter value is actually part of the + * operation's URL. + * This does not include the host or base path of the API. + * For example, in <code>/items/{itemId}</code>, the path parameter is <code>itemId</code>. + * <li><js>"query"</js> - Parameters that are appended to the URL. + * For example, in <code>/items?id=###</code>, the query parameter is <code>id</code>. + * <li><js>"header"</js> - Custom headers that are expected as part of the request. + * <li><js>"body"</js> - The payload that's appended to the HTTP request. + * Since there can only be one payload, there can only be one body parameter. + * The name of the body parameter has no effect on the parameter itself and is used for documentation purposes + * only. + * Since Form parameters are also in the payload, body and form parameters cannot exist together for the same + * operation. + * <li><js>"formData"</js> - Used to describe the payload of an HTTP request when either + * <code>application/x-www-form-urlencoded</code>, <code>multipart/form-data</code> or both are used as the + * content type of the request (in Swagger's definition, the consumes property of an operation). + * This is the only parameter type that can be used to send files, thus supporting the file type. + * Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the + * same operation. + * Form parameters have a different format based on the content-type used (for further details, consult + * <code>http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4</code>): + * <ul> + * <li><js>"application/x-www-form-urlencoded"</js> - Similar to the format of Query parameters but as a + * payload. + * For example, <code>foo=1&bar=swagger</code> - both <code>foo</code> and <code>bar</code> are form + * parameters. + * This is normally used for simple parameters that are being transferred. + * <li><js>"multipart/form-data"</js> - each parameter takes a section in the payload with an internal header. + * For example, for the header <code>Content-Disposition: form-data; name="submit-name"</code> the name of + * the parameter is <code>submit-name</code>. + * This type of form parameters is more commonly used for file transfers. + * </ul> + * </li> + * </ul> + * + * <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="in,name,type,description,required,schema,format,allowEmptyValue,items,collectionFormat,default,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,enum,multipleOf") +@SuppressWarnings("hiding") +public class ParameterInfo extends SwaggerElement { + + private static final String[] VALID_IN = {"query", "header", "path", "formData", "body"}; + private static final String[] VALID_TYPES = {"string", "number", "integer", "boolean", "array", "file"}; + private static final String[] VALID_COLLECTION_FORMATS = {"csv", "ssv", "tsv", "pipes", "multi"}; + + private String name; + private String in; + private String description; + private Boolean required; + private SchemaInfo schema; + private String type; + private String format; + private Boolean allowEmptyValue; + 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 ParameterInfo strict() { + super.strict(); + return this; + } + + /** + * Bean property getter: <property>name</property>. + * + * <p> + * Required. The name of the parameter. + * + * <p> + * Parameter names are case sensitive. + * If <code>in</code> is <js>"path"</js>, the <code>name</code> field MUST correspond to the associated path segment + * from the <code>path</code> field in the <a class="doclink" + * href="http://swagger.io/specification/#pathsObject">Paths Object</a>. + * See <a class="doclink" href="http://swagger.io/specification/#pathTemplating">Path Templating</a> for further + * information. + * For all other cases, the name corresponds to the parameter name used based on the <code>in</code> property. + * + * @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> + * Required. The name of the parameter. + * + * <p> + * Parameter names are case sensitive. + * If <code>in</code> is <js>"path"</js>, the <code>name</code> field MUST correspond to the associated path segment + * from the <code>path</code> field in the <a class="doclink" + * href="http://swagger.io/specification/#pathsObject">Paths Object</a>. + * See <a class="doclink" href="http://swagger.io/specification/#pathTemplating">Path Templating</a> for further + * information. + * For all other cases, the name corresponds to the parameter name used based on the <code>in</code> property. + * + * @param name The new value for the <property>name</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo setName(String name) { + if (! "body".equals(in)) + 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 ParameterInfo name(String name) { + return setName(name); + } + + /** + * Bean property getter: <property>in</property>. + * + * <p> + * Required. The location of the parameter. + * + * <p> + * Possible values are <js>"query"</js>, <js>"header"</js>, <js>"path"</js>, <js>"formData"</js> or <js>"body"</js>. + * + * @return The value of the <property>in</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getIn() { + return in; + } + + /** + * Bean property setter: <property>in</property>. + * + * <p> + * Required. The location of the parameter. + * + * <p> + * Possible values are <js>"query"</js>, <js>"header"</js>, <js>"path"</js>, <js>"formData"</js> or <js>"body"</js>. + * + * @param in The new value for the <property>in</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo setIn(String in) { + if (isStrict() && ! contains(in, VALID_IN)) + throw new FormattedRuntimeException( + "Invalid value passed in to setIn(String). Value=''{0}'', valid values={1}", + in, VALID_IN + ); + this.in = in; + if ("path".equals(in)) + required = true; + return this; + } + + /** + * Synonym for {@link #setIn(String)}. + * + * @param in The new value for the <property>in</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo in(String in) { + return setIn(in); + } + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * A brief description of the parameter. + * + * <p> + * This could contain examples of use. + * <a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> 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 brief description of the parameter. + * + * <p> + * This could contain examples of use. + * <a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> 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 ParameterInfo 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 ParameterInfo description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>required</property>. + * + * <p> + * Determines whether this parameter is mandatory. + * + * <p> + * If the parameter is <code>in</code> <js>"path"</js>, this property is required and its value MUST be + * <jk>true</jk>. + * Otherwise, the property MAY be included and its default value is <jk>false</jk>. + * + * @return The value of the <property>required</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Boolean getRequired() { + return required; + } + + /** + * Bean property setter: <property>required</property>. + * + * <p> + * Determines whether this parameter is mandatory. + * + * <p> + * If the parameter is <code>in</code> <js>"path"</js>, this property is required and its value MUST be + * <jk>true</jk>. + * Otherwise, the property MAY be included and its default value is <jk>false</jk>. + * + * @param required The new value for the <property>required</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo setRequired(Boolean required) { + this.required = required; + return this; + } + + /** + * Synonym for {@link #setRequired(Boolean)}. + * + * @param required The new value for the <property>required</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo required(Boolean required) { + return setRequired(required); + } + + /** + * Bean property getter: <property>schema</property>. + * + * <p> + * Required. The schema defining the type used for the body parameter. + * + * @return The value of the <property>schema</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public SchemaInfo getSchema() { + return schema; + } + + /** + * Bean property setter: <property>schema</property>. + * + * <p> + * Required. The schema defining the type used for the body parameter. + * + * @param schema The new value for the <property>schema</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo setSchema(SchemaInfo schema) { + this.schema = schema; + return this; + } + + /** + * Synonym for {@link #setSchema(SchemaInfo)}. + * + * @param schema The new value for the <property>schema</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo schema(SchemaInfo schema) { + return setSchema(schema); + } + + /** + * Bean property getter: <property>type</property>. + * + * <p> + * Required. The type of the parameter. + * + * <p> + * Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). + * The value MUST be one of <js>"string"</js>, <js>"number"</js>, <js>"integer"</js>, <js>"boolean"</js>, + * <js>"array"</js> or <js>"file"</js>. + * If type is <js>"file"</js>, the <code>consumes</code> MUST be either <js>"multipart/form-data"</js>, + * <js>"application/x-www-form-urlencoded"</js> or both and the parameter MUST be <code>in</code> + * <js>"formData"</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 parameter. + * + * <p> + * Since the parameter is not located at the request body, it is limited to simple types (that is, not an object). + * The value MUST be one of <js>"string"</js>, <js>"number"</js>, <js>"integer"</js>, <js>"boolean"</js>, + * <js>"array"</js> or <js>"file"</js>. + * If type is <js>"file"</js>, the <code>consumes</code> MUST be either <js>"multipart/form-data"</js>, + * <js>"application/x-www-form-urlencoded"</js> or both and the parameter MUST be <code>in</code> + * <js>"formData"</js>. + * + * @param type The new value for the <property>type</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo 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 ParameterInfo type(String type) { + return setType(type); + } + + /** + * Bean property getter: <property>format</property>. + * + * <p> + * The extending format for the previously mentioned type. + * + * <p> + * 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 type. + * + * <p> + * 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 ParameterInfo 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 ParameterInfo format(String format) { + return setFormat(format); + } + + /** + * Bean property getter: <property>allowEmptyValue</property>. + * + * <p> + * Sets the ability to pass empty-valued parameters. + * + * <p> + * This is valid only for either <code>query</code> or <code>formData</code> parameters and allows you to send a + * parameter with a name only or an empty value. + * Default value is <jk>false</jk>. + * + * @return The value of the <property>allowEmptyValue</property> property on this bean, or <jk>null</jk> if it is + * not set. + */ + public Boolean getAllowEmptyValue() { + return allowEmptyValue; + } + + /** + * Bean property setter: <property>allowEmptyValue</property>. + * + * <p> + * Sets the ability to pass empty-valued parameters. + * + * <p> + * This is valid only for either <code>query</code> or <code>formData</code> parameters and allows you to send a + * parameter with a name only or an empty value. + * Default value is <jk>false</jk>. + * + * @param allowEmptyValue The new value for the <property>allowEmptyValue</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo setAllowEmptyValue(Boolean allowEmptyValue) { + this.allowEmptyValue = allowEmptyValue; + return this; + } + + /** + * Synonym for {@link #setAllowEmptyValue(Boolean)}. + * + * @param allowEmptyValue The new value for the <property>allowEmptyValue</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo allowEmptyValue(Boolean allowEmptyValue) { + return setAllowEmptyValue(allowEmptyValue); + } + + /** + * Bean property getter: <property>items</property>. + * + * <p> + * Required if <code>type</code> is <js>"array"</js>. + * + * <p> + * 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>. + * + * <p> + * 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 ParameterInfo 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 ParameterInfo 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>. + * <li><code>multi</code> - corresponds to multiple parameter instances instead of multiple values for a single + * instance <code>foo=bar&foo=baz</code>. + * This is valid only for parameters <code>in</code> <js>"query"</js> or <js>"formData"</js>. + * </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>. + * <li><code>multi</code> - corresponds to multiple parameter instances instead of multiple values for a single + * instance <code>foo=bar&foo=baz</code>. + * This is valid only for parameters <code>in</code> <js>"query"</js> or <js>"formData"</js>. + * </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 ParameterInfo 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 ParameterInfo collectionFormat(String collectionFormat) { + return setCollectionFormat(collectionFormat); + } + + /** + * Bean property getter: <property>default</property>. + * + * <p> + * Declares the value of the parameter that the server will use if none is provided, for example a <js>"count"</js> + * to control the number of results per page might default to 100 if not supplied by the client in the request. + * (Note: <js>"default"</js> has no meaning for required parameters.) + * 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 this parameter. + * + * @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 parameter that the server will use if none is provided, for example a <js>"count"</js> + * to control the number of results per page might default to 100 if not supplied by the client in the request. + * (Note: <js>"default"</js> has no meaning for required parameters.) + * 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 this parameter. + * + * @param _default The new value for the <property>default</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo 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 ParameterInfo _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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo setMinLength(Integer minLength) { + this.minLength = minLength; + return this; + } + + /** + * Synonym for {@link #setMinLength(Integer)}. + * + * @param minLength The new value for the <property>minLength</property> property on this bean. + * @return This object (for method chaining). + */ + public ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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 ParameterInfo 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). + */ + @SuppressWarnings("unchecked") + public ParameterInfo 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 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 ParameterInfo _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 ParameterInfo 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 ParameterInfo 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/ResponseInfo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java new file mode 100644 index 0000000..6fda9a7 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/ResponseInfo.java @@ -0,0 +1,276 @@ +// *************************************************************************************************************************** +// * 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 java.util.*; + +import org.apache.juneau.annotation.*; + +/** + * Describes a single response from an API Operation. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"description"</js>: <js>"A complex object array response"</js>, + * <js>"schema"</js>: { + * <js>"type"</js>: <js>"array"</js>, + * <js>"items"</js>: { + * <js>"$ref"</js>: <js>"#/definitions/VeryComplexType"</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,schema,headers,examples") +@SuppressWarnings("hiding") +public class ResponseInfo extends SwaggerElement { + + private String description; + private SchemaInfo schema; + private Map<String,HeaderInfo> headers; + private Map<String,Object> examples; + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * Required. A short description of the response. + * + * <p> + * <a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> 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> + * Required. A short description of the response. + * + * <p> + * <a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> 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 ResponseInfo 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 ResponseInfo description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>schema</property>. + * + * <p> + * A definition of the response structure. + * + * <p> + * It can be a primitive, an array or an object. + * If this field does not exist, it means no content is returned as part of the response. + * As an extension to the <a class="doclink" href="http://swagger.io/specification/#schemaObject">Schema Object</a>, + * its root type value may also be <js>"file"</js>. + * This SHOULD be accompanied by a relevant produces mime-type. + * + * @return The value of the <property>schema</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public SchemaInfo getSchema() { + return schema; + } + + /** + * Bean property setter: <property>schema</property>. + * + * <p> + * A definition of the response structure. + * + * <p> + * It can be a primitive, an array or an object. + * If this field does not exist, it means no content is returned as part of the response. + * As an extension to the <a class="doclink" href="http://swagger.io/specification/#schemaObject">Schema Object</a>, + * its root type value may also be <js>"file"</js>. + * This SHOULD be accompanied by a relevant produces mime-type. + * + * @param schema The new value for the <property>schema</property> property on this bean. + * @return This object (for method chaining). + */ + public ResponseInfo setSchema(SchemaInfo schema) { + this.schema = schema; + return this; + } + + /** + * Synonym for {@link #setSchema(SchemaInfo)}. + * + * @param schema The new value for the <property>schema</property> property on this bean. + * @return This object (for method chaining). + */ + public ResponseInfo schema(SchemaInfo schema) { + return setSchema(schema); + } + + /** + * Bean property getter: <property>headers</property>. + * + * <p> + * A list of headers that are sent with the response. + * + * @return The value of the <property>headers</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Map<String,HeaderInfo> getHeaders() { + return headers; + } + + /** + * Bean property setter: <property>headers</property>. + * + * <p> + * A list of headers that are sent with the response. + * + * @param headers The new value for the <property>headers</property> property on this bean. + * @return This object (for method chaining). + */ + public ResponseInfo setHeaders(Map<String,HeaderInfo> headers) { + this.headers = headers; + return this; + } + + /** + * Bean property adder: <property>headers</property>. + * + * <p> + * A list of headers that are sent with the response. + * + * @param name The header name. + * @param header The header descriptions + * @return This object (for method chaining). + */ + public ResponseInfo addHeader(String name, HeaderInfo header) { + if (headers == null) + headers = new TreeMap<String,HeaderInfo>(); + headers.put(name, header); + return this; + } + + /** + * Synonym for {@link #addHeader(String,HeaderInfo)}. + * + * @param name The header name. + * @param header The header descriptions + * @return This object (for method chaining). + */ + public ResponseInfo header(String name, HeaderInfo header) { + return addHeader(name, header); + } + + /** + * Bean property getter: <property>examples</property>. + * + * <p> + * An example of the response message. + * + * <p> + * Keys must be MIME-type strings. + * + * @return The value of the <property>examples</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Map<String,Object> getExamples() { + return examples; + } + + /** + * Bean property setter: <property>examples</property>. + * + * <p> + * An example of the response message. + * + * <p> + * Keys must be MIME-type strings. + * + * @param examples The new value for the <property>examples</property> property on this bean. + * @return This object (for method chaining). + */ + public ResponseInfo setExamples(Map<String,Object> examples) { + this.examples = examples; + return this; + } + + /** + * Bean property adder: <property>examples</property>. + * + * <p> + * An example of the response message. + * + * @param mimeType The mimeType of the example. + * @param example The example output. + * @return This object (for method chaining). + */ + public ResponseInfo addExample(String mimeType, Object example) { + if (examples == null) + examples = new TreeMap<String,Object>(); + examples.put(mimeType, example); + return this; + } + + /** + * Synonym for {@link #addExample(String,Object)}. + * + * @param mimeType The mimeType of the example. + * @param example The example output. + * @return This object (for method chaining). + */ + public ResponseInfo example(String mimeType, Object example) { + return addExample(mimeType, example); + } + + /** + * Synonym for {@link #setExamples(Map)}. + * + * @param examples The new value for the <property>examples</property> property on this bean. + * @return This object (for method chaining). + */ + public ResponseInfo examples(Map<String,Object> examples) { + return setExamples(examples); + } +} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/SchemaInfo.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/SchemaInfo.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/SchemaInfo.java new file mode 100644 index 0000000..f52fd6b --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/SchemaInfo.java @@ -0,0 +1,1057 @@ +// *************************************************************************************************************************** +// * 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 java.util.*; + +import org.apache.juneau.annotation.*; + +/** + * The Schema Object allows the definition of input and output data types. + * + * <p> + * These types can be objects, but also primitives and arrays. + * This object is based on the JSON Schema Specification Draft 4 and uses a predefined subset of it. + * On top of this subset, there are extensions provided by this specification to allow for more complete documentation. + * + * <p> + * Further information about the properties can be found in JSON Schema Core and JSON Schema Validation. + * Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here. + * + * <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="format,title,description,default,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,maxProperties,minProperties,required,enum,type,items,allOf,properties,additionalProperties,discriminator,readOnly,xml,externalDocs,example") +@SuppressWarnings({ "hiding", "unchecked" }) +public class SchemaInfo extends SwaggerElement { + + private String format; + private String title; + private String description; + private Object _default; + private Number multipleOf; + 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 Integer maxProperties; + private Integer minProperties; + private Boolean required; + private List<Object> _enum; + private String type; + private Items items; + private List<Object> allOf; + private Map<String,Map<String,Object>> properties; + private Map<String,Object> additionalProperties; + private String discriminator; + private Boolean readOnly; + private Xml xml; + private ExternalDocumentation externalDocs; + private Object example; + + /** + * Bean property getter: <property>format</property>. + * + * <p> + * 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> + * 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 SchemaInfo 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 SchemaInfo format(String format) { + return setFormat(format); + } + + /** + * Bean property getter: <property>title</property>. + * + * @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>. + * + * @param title The new value for the <property>title</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo title(String title) { + return setTitle(title); + } + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * <a class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> 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 class="doclink" href="https://help.github.com/articles/github-flavored-markdown">GFM syntax</a> 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 SchemaInfo 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 SchemaInfo description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>default</property>. + * + * <p> + * Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object. + * + * @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> + * Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object. + * + * @param _default The new value for the <property>default</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo _default(Object _default) { + return setDefault(_default); + } + + /** + * Bean property getter: <property>multipleOf</property>. + * + * @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>. + * + * @param multipleOf The new value for the <property>multipleOf</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo multipleOf(Number multipleOf) { + return setMultipleOf(multipleOf); + } + + /** + * Bean property getter: <property>maximum</property>. + * + * @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>. + * + * @param maximum The new value for the <property>maximum</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo maximum(Number maximum) { + return setMaximum(maximum); + } + + /** + * Bean property getter: <property>exclusiveMaximum</property>. + * + * @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>. + * + * @param exclusiveMaximum The new value for the <property>exclusiveMaximum</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo exclusiveMaximum(Boolean exclusiveMaximum) { + return setExclusiveMaximum(exclusiveMaximum); + } + + /** + * Bean property getter: <property>minimum</property>. + * + * @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>. + * + * @param minimum The new value for the <property>minimum</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo minimum(Number minimum) { + return setMinimum(minimum); + } + + /** + * Bean property getter: <property>exclusiveMinimum</property>. + * + * @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>. + * + * @param exclusiveMinimum The new value for the <property>exclusiveMinimum</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo exclusiveMinimum(Boolean exclusiveMinimum) { + return setExclusiveMinimum(exclusiveMinimum); + } + + /** + * Bean property getter: <property>maxLength</property>. + * + * @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>. + * + * @param maxLength The new value for the <property>maxLength</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo maxLength(Integer maxLength) { + return setMaxLength(maxLength); + } + + /** + * Bean property getter: <property>minLength</property>. + * + * @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>. + * + * @param minLength The new value for the <property>minLength</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setMinLength(Integer minLength) { + this.minLength = minLength; + return this; + } + + /** + * Synonym for {@link #setMinLength(Integer)}. + * + * @param minLength The new value for the <property>minLength</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo minLength(Integer minLength) { + return setMinLength(minLength); + } + + /** + * Bean property getter: <property>pattern</property>. + * + * @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>. + * + * @param pattern The new value for the <property>pattern</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo pattern(String pattern) { + return setPattern(pattern); + } + + /** + * Bean property getter: <property>maxItems</property>. + * + * @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>. + * + * @param maxItems The new value for the <property>maxItems</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo maxItems(Integer maxItems) { + return setMaxItems(maxItems); + } + + /** + * Bean property getter: <property>minItems</property>. + * + * @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>. + * + * @param minItems The new value for the <property>minItems</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo minItems(Integer minItems) { + return setMinItems(minItems); + } + + /** + * Bean property getter: <property>uniqueItems</property>. + * + * @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>. + * + * @param uniqueItems The new value for the <property>uniqueItems</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo uniqueItems(Boolean uniqueItems) { + return setUniqueItems(uniqueItems); + } + + /** + * Bean property getter: <property>maxProperties</property>. + * + * @return The value of the <property>maxProperties</property> property on this bean, or <jk>null</jk> if it is + * not set. + */ + public Integer getMaxProperties() { + return maxProperties; + } + + /** + * Bean property setter: <property>maxProperties</property>. + * + * @param maxProperties The new value for the <property>maxProperties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setMaxProperties(Integer maxProperties) { + this.maxProperties = maxProperties; + return this; + } + + /** + * Synonym for {@link #setMaxProperties(Integer)}. + * + * @param maxProperties The new value for the <property>maxProperties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo maxProperties(Integer maxProperties) { + return setMaxProperties(maxProperties); + } + + /** + * Bean property getter: <property>minProperties</property>. + * + * @return The value of the <property>minProperties</property> property on this bean, or <jk>null</jk> if it is + * not set. + */ + public Integer getMinProperties() { + return minProperties; + } + + /** + * Bean property setter: <property>minProperties</property>. + * + * @param minProperties The new value for the <property>minProperties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setMinProperties(Integer minProperties) { + this.minProperties = minProperties; + return this; + } + + /** + * Synonym for {@link #setMinProperties(Integer)}. + * + * @param minProperties The new value for the <property>minProperties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo minProperties(Integer minProperties) { + return setMinProperties(minProperties); + } + + /** + * Bean property getter: <property>required</property>. + * + * @return The value of the <property>required</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Boolean getRequired() { + return required; + } + + /** + * Bean property setter: <property>required</property>. + * + * @param required The new value for the <property>required</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setRequired(Boolean required) { + this.required = required; + return this; + } + + /** + * Synonym for {@link #setRequired(Boolean)}. + * + * @param required The new value for the <property>required</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo required(Boolean required) { + return setRequired(required); + } + + /** + * Bean property getter: <property>enum</property>. + * + * @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>. + * + * @param _enum The new value for the <property>enum</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setEnum(List<Object> _enum) { + this._enum = _enum; + return this; + } + + /** + * Bean property adder: <property>enum</property>. + * + * @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 SchemaInfo 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 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 SchemaInfo _enum(Object..._enum) { + return addEnum(_enum); + } + + /** + * Bean property getter: <property>type</property>. + * + * @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>. + * + * @param type The new value for the <property>type</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setType(String type) { + 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 SchemaInfo type(String type) { + return setType(type); + } + + /** + * Bean property getter: <property>items</property>. + * + * @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>. + * + * @param items The new value for the <property>items</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo 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 SchemaInfo items(Items items) { + return setItems(items); + } + + /** + * Bean property getter: <property>allOf</property>. + * + * @return The value of the <property>allOf</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<Object> getAllOf() { + return allOf; + } + + /** + * Bean property setter: <property>allOf</property>. + * + * @param allOf The new value for the <property>allOf</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setAllOf(List<Object> allOf) { + this.allOf = allOf; + return this; + } + + /** + * Bean property adder: <property>enum</property>. + * + * @param allOf + * The new values to add to the <property>allOf</property> property on this bean. + * These can either be individual objects or {@link Collection Collections} of objects. + * @return This object (for method chaining). + */ + public SchemaInfo addAllOf(Object...allOf) { + for (Object o : allOf) { + if (o != null) { + if (o instanceof Collection) + addAllOf((Collection<Object>)o); + else { + if (this.allOf == null) + this.allOf = new LinkedList<Object>(); + this.allOf.add(o); + } + } + } + return this; + } + + /** + * Synonym for {@link #addAllOf(Object...)}. + * + * @param allOf + * The new values to add to the <property>allOf</property> property on this bean. + * These can either be individual objects or {@link Collection Collections} of objects. + * @return This object (for method chaining). + */ + public SchemaInfo allOf(Object...allOf) { + return addAllOf(allOf); + } + + /** + * Bean property getter: <property>properties</property>. + * + * @return The value of the <property>properties</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Map<String,Map<String,Object>> getProperties() { + return properties; + } + + /** + * Bean property setter: <property>properties</property>. + * + * @param properties The new value for the <property>properties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setProperties(Map<String,Map<String,Object>> properties) { + this.properties = properties; + return this; + } + + /** + * Bean property setter: <property>properties</property>. + * + * @param name The property name. + * @param propertyProperties The properties of the property. + * @return This object (for method chaining). + */ + public SchemaInfo addProperty(String name, Map<String,Object> propertyProperties) { + if (this.properties == null) + this.properties = new TreeMap<String,Map<String,Object>>(); + this.properties.put(name, propertyProperties); + return this; + } + + /** + * Synonym for {@link #addProperty(String,Map)}. + * + * @param name The property name. + * @param propertyProperties The properties of the property. + * @return This object (for method chaining). + */ + public SchemaInfo property(String name, Object...propertyProperties) { + if (propertyProperties.length % 2 != 0) + throw new RuntimeException("Invalid number of arguments passed to SchemaInfo.property(String,Object...)"); + Map<String,Object> m = new LinkedHashMap<String,Object>(); + for (int i = 0; i < propertyProperties.length; i += 2) + m.put(String.valueOf(propertyProperties[i]), propertyProperties[i+1]); + return addProperty(name, m); + } + + /** + * Bean property getter: <property>additionalProperties</property>. + * + * @return + * The value of the <property>additionalProperties</property> property on this bean, or <jk>null</jk> if it + * is not set. + */ + public Map<String,Object> getAdditionalProperties() { + return additionalProperties; + } + + /** + * Bean property setter: <property>additionalProperties</property>. + * + * @param additionalProperties The new value for the <property>additionalProperties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setAdditionalProperties(Map<String,Object> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * Synonym for {@link #setAdditionalProperties(Map)}. + * + * @param additionalProperties The new value for the <property>additionalProperties</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo additionalProperties(Object...additionalProperties) { + if (additionalProperties.length % 2 != 0) + throw new RuntimeException("Invalid number of arguments passed to SchemaInfo.additionalProperties(Object...)"); + Map<String,Object> m = new LinkedHashMap<String,Object>(); + for (int i = 0; i < additionalProperties.length; i += 2) + m.put(String.valueOf(additionalProperties[i]), additionalProperties[i+1]); + return setAdditionalProperties(m); + } + + /** + * Bean property getter: <property>discriminator</property>. + * + * @return + * The value of the <property>discriminator</property> property on this bean, or <jk>null</jk> if it is + * not set. + */ + public String getDiscriminator() { + return discriminator; + } + + /** + * Bean property setter: <property>discriminator</property>. + * + * @param discriminator The new value for the <property>discriminator</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setDiscriminator(String discriminator) { + this.discriminator = discriminator; + return this; + } + + /** + * Synonym for {@link #setDiscriminator(String)}. + * + * @param discriminator The new value for the <property>discriminator</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo discriminator(String discriminator) { + return setDiscriminator(discriminator); + } + + /** + * Bean property getter: <property>readOnly</property>. + * + * @return The value of the <property>readOnly</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Boolean getReadOnly() { + return readOnly; + } + + /** + * Bean property setter: <property>readOnly</property>. + * + * @param readOnly The new value for the <property>readOnly</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + return this; + } + + /** + * Synonym for {@link #setReadOnly(Boolean)}. + * + * @param readOnly The new value for the <property>readOnly</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo readOnly(Boolean readOnly) { + return setReadOnly(readOnly); + } + + /** + * Bean property getter: <property>xml</property>. + * + * @return The value of the <property>xml</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Xml getXml() { + return xml; + } + + /** + * Bean property setter: <property>xml</property>. + * + * @param xml The new value for the <property>xml</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setXml(Xml xml) { + this.xml = xml; + return this; + } + + /** + * Synonym for {@link #setXml(Xml)}. + * + * @param xml The new value for the <property>xml</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo xml(Xml xml) { + return setXml(xml); + } + + /** + * Bean property getter: <property>externalDocs</property>. + * + * @return + * The value of the <property>externalDocs</property> property on this bean, or <jk>null</jk> if it is not + * set. + */ + public ExternalDocumentation getExternalDocs() { + return externalDocs; + } + + /** + * Bean property setter: <property>externalDocs</property>. + * + * @param externalDocs The new value for the <property>externalDocs</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setExternalDocs(ExternalDocumentation externalDocs) { + this.externalDocs = externalDocs; + return this; + } + + /** + * Synonym for {@link #setExternalDocs(ExternalDocumentation)}. + * + * @param externalDocs The new value for the <property>externalDocs</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo externalDocs(ExternalDocumentation externalDocs) { + return setExternalDocs(externalDocs); + } + + /** + * Bean property getter: <property>example</property>. + * + * @return The value of the <property>example</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Object getExample() { + return example; + } + + /** + * Bean property setter: <property>example</property>. + * + * @param example The new value for the <property>example</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo setExample(Object example) { + this.example = example; + return this; + } + + /** + * Synonym for {@link #setExample(Object)}. + * + * @param example The new value for the <property>example</property> property on this bean. + * @return This object (for method chaining). + */ + public SchemaInfo example(Object example) { + return setExample(example); + } +}
