http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/75b0d8ee/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Items.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Items.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Items.java new file mode 100644 index 0000000..a9b2d19 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Items.java @@ -0,0 +1,799 @@ +// *************************************************************************************************************************** +// * 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.*; +import org.apache.juneau.json.*; + +/** + * A limited subset of JSON-Schema's items object. It is used by parameter definitions that are not located in "body". + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"type"</js>: <js>"string"</js>, + * <js>"minLength"</js>: 2 + * } + * </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="type,format,items,collectionFormat,default,maximum,exclusiveMaximum,minimum,exclusiveMinimum,maxLength,minLength,pattern,maxItems,minItems,uniqueItems,enum,multipleOf") +@SuppressWarnings({ "hiding", "unchecked" }) +public class Items 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 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 Items strict() { + super.strict(); + return this; + } + + /** + * Bean property getter: <property>type</property>. + * + * <p> + * Required. The internal type of the array. + * 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 internal type of the array. + * 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 Items setType(String type) { + if (isStrict() && ! contains(type, VALID_TYPES)) + throw new RuntimeException( + "Invalid value passed in to setType(String). Value='"+type+"', valid values=" + + JsonSerializer.DEFAULT_LAX.toString(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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items collectionFormat(String collectionFormat) { + return setCollectionFormat(collectionFormat); + } + + /** + * Bean property getter: <property>default</property>. + * + * <p> + * Declares the value of the item 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 data type. + * + * @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 item 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 data type. + * + * @param _default The new value for the <property>default</property> property on this bean. + * @return This object (for method chaining). + */ + public Items 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 Items _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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items 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 Items _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 Items 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 Items 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/License.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java new file mode 100644 index 0000000..3b837ac --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/License.java @@ -0,0 +1,138 @@ +// *************************************************************************************************************************** +// * 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.*; + +/** + * License information for the exposed API. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"name"</js>: <js>"Apache 2.0"</js>, + * <js>"url"</js>: <js>"http://www.apache.org/licenses/LICENSE-2.0.html"</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") +@SuppressWarnings("hiding") +public class License extends SwaggerElement { + + private String name; + private URI url; + + /** + * Bean property getter: <property>name</property>. + * + * <p> + * Required. The license name used for the API. + * + * @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 license name used for the API. + * + * @param name The new value for the <property>name</property> property on this bean. + * @return This object (for method chaining). + */ + public License 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 License name(String name) { + return setName(name); + } + + /** + * Bean property getter: <property>url</property>. + * + * <p> + * A URL to the license used for the API. + * + * <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 License 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 License 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/Operation.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java new file mode 100644 index 0000000..4766b40 --- /dev/null +++ b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Operation.java @@ -0,0 +1,871 @@ +// *************************************************************************************************************************** +// * 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.*; +import org.apache.juneau.http.*; + +/** + * Describes a single API operation on a path. + * + * <h5 class='section'>Example:</h5> + * <p class='bcode'> + * { + * <js>"tags"</js>: [ + * <js>"pet"</js> + * ], + * <js>"summary"</js>: <js>"Updates a pet in the store with form data"</js>, + * <js>"description"</js>: "", + * <js>"operationId"</js>: <js>"updatePetWithForm"</js>, + * <js>"consumes"</js>: [ + * <js>"application/x-www-form-urlencoded"</js> + * ], + * <js>"produces"</js>: [ + * <js>"application/json"</js>, + * <js>"application/xml"</js> + * ], + * <js>"parameters"</js>: [ + * { + * <js>"name"</js>: <js>"petId"</js>, + * <js>"in"</js>: <js>"path"</js>, + * <js>"description"</js>: <js>"ID of pet that needs to be updated"</js>, + * <js>"required"</js>: <jk>true</jk>, + * <js>"type"</js>: <js>"string"</js> + * }, + * { + * <js>"name"</js>: <js>"name"</js>, + * <js>"in"</js>: <js>"formData"</js>, + * <js>"description"</js>: <js>"Updated name of the pet"</js>, + * <js>"required"</js>: <jk>false</jk>, + * <js>"type"</js>: <js>"string"</js> + * }, + * { + * <js>"name"</js>: <js>"status"</js>, + * <js>"in"</js>: <js>"formData"</js>, + * <js>"description"</js>: <js>"Updated status of the pet"</js>, + * <js>"required"</js>: <jk>false</jk>, + * <js>"type"</js>: <js>"string"</js> + * } + * ], + * <js>"responses"</js>: { + * <js>"200"</js>: { + * <js>"description"</js>: <js>"Pet updated."</js> + * }, + * <js>"405"</js>: { + * <js>"description"</js>: <js>"Invalid input"</js> + * } + * }, + * <js>"security"</js>: [ + * { + * <js>"petstore_auth"</js>: [ + * <js>"write:pets"</js>, + * <js>"read:pets"</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="operationId,summary,description,tags,externalDocs,consumes,produces,parameters,responses,schemes,deprecated,security") +@SuppressWarnings("hiding") +public class Operation extends SwaggerElement { + + private List<String> tags; + private String summary; + private String description; + private ExternalDocumentation externalDocs; + private String operationId; + private List<MediaType> consumes; + private List<MediaType> produces; + private List<ParameterInfo> parameters; + private Map<Integer,ResponseInfo> responses; + private List<String> schemes; + private Boolean deprecated; + private List<Map<String,List<String>>> security; + + /** + * Bean property getter: <property>tags</property>. + * + * <p> + * A list of tags for API documentation control. + * Tags can be used for logical grouping of operations by resources or any other qualifier. + * + * @return The value of the <property>tags</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<String> getTags() { + return tags; + } + + /** + * Bean property setter: <property>tags</property>. + * + * <p> + * A list of tags for API documentation control. + * Tags can be used for logical grouping of operations by resources or any other qualifier. + * + * @param tags The new value for the <property>tags</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setTags(List<String> tags) { + this.tags = tags; + return this; + } + + /** + * Bean property adder: <property>tags</property>. + * + * <p> + * A list of tags for API documentation control. + * Tags can be used for logical grouping of operations by resources or any other qualifier. + * + * @param tags The values to add for the <property>tags</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addTags(String...tags) { + return addTags(Arrays.asList(tags)); + } + + /** + * Bean property adder: <property>tags</property>. + * + * <p> + * A list of tags for API documentation control. + * Tags can be used for logical grouping of operations by resources or any other qualifier. + * + * @param tags + * The values to add for the <property>tags</property> property on this bean. + * Ignored if <jk>null</jk>. + * @return This object (for method chaining). + */ + public Operation addTags(Collection<String> tags) { + if (tags != null) { + if (this.tags == null) + this.tags = new LinkedList<String>(); + this.tags.addAll(tags); + } + return this; + } + + /** + * Synonym for {@link #addTags(String...)}. + * + * @param tags The new value for the <property>tags</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation tags(String...tags) { + return addTags(tags); + } + + /** + * Synonym for {@link #addTags(Collection)}. + * + * @param tags The new value for the <property>tags</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation tags(Collection<String> tags) { + return addTags(tags); + } + + /** + * Bean property getter: <property>summary</property>. + * + * <p> + * A short summary of what the operation does. + * For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters. + * + * @return The value of the <property>summary</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getSummary() { + return summary; + } + + /** + * Bean property setter: <property>summary</property>. + * + * <p> + * A short summary of what the operation does. + * For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters. + * + * @param summary The new value for the <property>summary</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setSummary(String summary) { + this.summary = summary; + return this; + } + + /** + * Synonym for {@link #setSummary(String)}. + * + * @param summary The new value for the <property>summary</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation summary(String summary) { + return setSummary(summary); + } + + /** + * Bean property getter: <property>description</property>. + * + * <p> + * A verbose explanation of the operation behavior. + * <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 verbose explanation of the operation behavior. + * <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 Operation 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 Operation description(String description) { + return setDescription(description); + } + + /** + * Bean property getter: <property>externalDocs</property>. + * + * <p> + * Additional external documentation for this operation. + * + * @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>. + * + * <p> + * Additional external documentation for this operation. + * + * @param externalDocs The new value for the <property>externalDocs</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation 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 Operation externalDocs(ExternalDocumentation externalDocs) { + return setExternalDocs(externalDocs); + } + + /** + * Bean property getter: <property>operationId</property>. + * + * <p> + * Unique string used to identify the operation. The id MUST be unique among all operations described in the API. + * Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to + * follow common programming naming conventions. + * + * @return + * The value of the <property>operationId</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public String getOperationId() { + return operationId; + } + + /** + * Bean property setter: <property>operationId</property>. + * + * <p> + * Unique string used to identify the operation. The id MUST be unique among all operations described in the API. + * Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to + * follow common programming naming conventions. + * + * @param operationId The new value for the <property>operationId</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setOperationId(String operationId) { + this.operationId = operationId; + return this; + } + + /** + * Synonym for {@link #setOperationId(String)}. + * + * @param operationId The new value for the <property>operationId</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation operationId(String operationId) { + return setOperationId(operationId); + } + + /** + * Bean property getter: <property>consumes</property>. + * + * <p> + * A list of MIME types the operation can consume. + * This overrides the <code>consumes</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @return The value of the <property>consumes</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<MediaType> getConsumes() { + return consumes; + } + + /** + * Bean property setter: <property>consumes</property>. + * + * <p> + * A list of MIME types the operation can consume. + * This overrides the <code>consumes</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @param consumes The new value for the <property>consumes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setConsumes(List<MediaType> consumes) { + this.consumes = consumes; + return this; + } + + /** + * Bean property adder: <property>consumes</property>. + * + * <p> + * A list of MIME types the operation can consume. + * This overrides the <code>consumes</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @param consumes The new values to add to the <property>consumes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addConsumes(MediaType...consumes) { + return addConsumes(Arrays.asList(consumes)); + } + + /** + * Bean property adder: <property>consumes</property>. + * + * <p> + * A list of MIME types the operation can consume. + * This overrides the <code>consumes</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @param consumes The new values to add to the <property>consumes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addConsumes(Collection<MediaType> consumes) { + if (consumes != null) { + if (this.consumes == null) + this.consumes = new LinkedList<MediaType>(); + this.consumes.addAll(consumes); + } + return this; + } + + /** + * Synonym for {@link #addConsumes(MediaType...)}. + * + * @param consumes The new values to add to the <property>consumes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation consumes(MediaType...consumes) { + return addConsumes(consumes); + } + + /** + * Synonym for {@link #addConsumes(Collection)}. + * + * @param consumes The new values to add to the <property>consumes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation consumes(Collection<MediaType> consumes) { + return addConsumes(consumes); + } + + /** + * Bean property getter: <property>produces</property>. + * + * <p> + * A list of MIME types the operation can produce. + * This overrides the <code>produces</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @return The value of the <property>produces</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<MediaType> getProduces() { + return produces; + } + + /** + * Bean property setter: <property>produces</property>. + * + * <p> + * A list of MIME types the operation can produce. + * This overrides the <code>produces</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @param produces The new value for the <property>produces</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setProduces(List<MediaType> produces) { + this.produces = produces; + return this; + } + + /** + * Bean property adder: <property>produces</property>. + * + * <p> + * A list of MIME types the operation can produce. + * This overrides the <code>produces</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @param produces The new value for the <property>produces</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addProduces(MediaType...produces) { + if (produces != null) { + if (this.produces == null) + this.produces = new LinkedList<MediaType>(); + this.produces.addAll(Arrays.asList(produces)); + } + return this; + } + + /** + * Bean property adder: <property>produces</property>. + * + * <p> + * A list of MIME types the operation can produces. + * This overrides the <code>produces</code> definition at the Swagger Object. + * An empty value MAY be used to clear the global definition. + * Value MUST be as described under <a class="doclink" href="http://swagger.io/specification/#mimeTypes">Mime Types</a>. + * + * @param produces The new values to add to the <property>produces</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addProduces(Collection<MediaType> produces) { + if (produces != null) { + if (this.produces == null) + this.produces = new LinkedList<MediaType>(); + this.produces.addAll(produces); + } + return this; + } + + /** + * Synonym for {@link #addProduces(MediaType...)}. + * + * @param produces The new value for the <property>produces</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation produces(MediaType...produces) { + return addProduces(produces); + } + + /** + * Synonym for {@link #addProduces(Collection)}. + * + * @param produces The new value for the <property>produces</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation produces(Collection<MediaType> produces) { + return addProduces(produces); + } + + /** + * Bean property getter: <property>parameters</property>. + * + * <p> + * A list of parameters that are applicable for this operation. + * If a parameter is already defined at the <a class="doclink" + * href="http://swagger.io/specification/#pathItemParameters">Path Item</a>, the new definition will override it, + * but can never remove it. + * The list MUST NOT include duplicated parameters. + * A unique parameter is defined by a combination of a <code>name</code> and <code>location</code>. + * The list can use the <a class="doclink" href="http://swagger.io/specification/#referenceObject">Reference Object</a> + * to link to parameters that are defined at the <a class="doclink" href="http://swagger.io/specification/#swaggerParameters">Swagger Object's parameters</a>. + * There can be one <js>"body"</js> parameter at most. + * + * @return The value of the <property>parameters</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<ParameterInfo> getParameters() { + return parameters; + } + + /** + * Bean property setter: <property>parameters</property>. + * + * <p> + * A list of parameters that are applicable for this operation. + * If a parameter is already defined at the <a class="doclink" + * href="http://swagger.io/specification/#pathItemParameters">Path Item</a>, the new definition will override it, + * but can never remove it. + * The list MUST NOT include duplicated parameters. + * A unique parameter is defined by a combination of a <code>name</code> and <code>location</code>. + * The list can use the <a class="doclink" + * href="http://swagger.io/specification/#referenceObject">Reference Object</a> to link to parameters that are + * defined at the <a class="doclink" + * href="http://swagger.io/specification/#swaggerParameters">Swagger Object's parameters</a>. + * There can be one <js>"body"</js> parameter at most. + * + * @param parameters The new value for the <property>parameters</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setParameters(List<ParameterInfo> parameters) { + this.parameters = parameters; + return this; + } + + /** + * Bean property adder: <property>parameters</property>. + * + * <p> + * A list of parameters that are applicable for this operation. + * If a parameter is already defined at the <a class="doclink" + * href="http://swagger.io/specification/#pathItemParameters">Path Item</a>, the new definition will override it, + * but can never remove it. + * The list MUST NOT include duplicated parameters. + * A unique parameter is defined by a combination of a <code>name</code> and <code>location</code>. + * The list can use the <a class="doclink" + * href="http://swagger.io/specification/#referenceObject">Reference Object</a> to link to parameters that are + * defined at the <a class="doclink" + * href="http://swagger.io/specification/#swaggerParameters">Swagger Object's parameters</a>. + * There can be one <js>"body"</js> parameter at most. + * + * @param parameters The new value to add to the <property>parameters</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addParameters(ParameterInfo...parameters) { + if (this.parameters == null) + this.parameters = new LinkedList<ParameterInfo>(); + this.parameters.addAll(Arrays.asList(parameters)); + return this; + } + + /** + * Synonym for {@link #addParameters(ParameterInfo...)}. + * + * @param parameters The new value to add to the <property>parameters</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation parameters(ParameterInfo...parameters) { + return addParameters(parameters); + } + + /** + * Synonym for {@link #setParameters(List)}. + * + * @param parameters The new value to add to the <property>parameters</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation parameters(List<ParameterInfo> parameters) { + return setParameters(parameters); + } + + /** + * Bean property getter: <property>responses</property>. + * + * <p> + * Required. The list of possible responses as they are returned from executing this operation. + * + * @return The value of the <property>responses</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Map<Integer,ResponseInfo> getResponses() { + return responses; + } + + /** + * Bean property setter: <property>responses</property>. + * + * <p> + * Required. The list of possible responses as they are returned from executing this operation. + * + * @param responses The new value for the <property>responses</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setResponses(Map<Integer,ResponseInfo> responses) { + this.responses = responses; + return this; + } + + /** + * Bean property adder: <property>responses</property>. + * + * <p> + * Required. The list of possible responses as they are returned from executing this operation. + * + * @param statusCode The HTTP status code. + * @param response The response description. + * @return This object (for method chaining). + */ + public Operation addResponse(Integer statusCode, ResponseInfo response) { + if (responses == null) + responses = new TreeMap<Integer,ResponseInfo>(); + responses.put(statusCode, response); + return this; + } + + /** + * Synonym for {@link #addResponse(Integer,ResponseInfo)}. + * + * @param statusCode The HTTP status code. + * @param response The response description. + * @return This object (for method chaining). + */ + public Operation response(Integer statusCode, ResponseInfo response) { + return addResponse(statusCode, response); + } + + /** + * Synonym for {@link #setResponses(Map)}. + * + * @param responses The new value for the <property>responses</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation responses(Map<Integer,ResponseInfo> responses) { + return setResponses(responses); + } + + /** + * Bean property getter: <property>schemes</property>. + * + * <p> + * The transfer protocol for the operation. + * Values MUST be from the list: <js>"http"</js>, <js>"https"</js>, <js>"ws"</js>, <js>"wss"</js>. + * The value overrides the Swagger Object <code>schemes</code> definition. + * + * @return The value of the <property>schemes</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<String> getSchemes() { + return schemes; + } + + /** + * Bean property setter: <property>schemes</property>. + * + * <p> + * The transfer protocol for the operation. + * Values MUST be from the list: <js>"http"</js>, <js>"https"</js>, <js>"ws"</js>, <js>"wss"</js>. + * The value overrides the Swagger Object <code>schemes</code> definition. + * + * @param schemes The new value for the <property>schemes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setSchemes(List<String> schemes) { + this.schemes = schemes; + return this; + } + + /** + * Bean property adder: <property>schemes</property>. + * + * <p> + * The transfer protocol for the operation. + * Values MUST be from the list: <js>"http"</js>, <js>"https"</js>, <js>"ws"</js>, <js>"wss"</js>. + * The value overrides the Swagger Object <code>schemes</code> definition. + * + * @param schemes The new values to add to the <property>schemes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addSchemes(String...schemes) { + return addSchemes(Arrays.asList(schemes)); + } + + /** + * Bean property adder: <property>schemes</property>. + * + * <p> + * The transfer protocol for the operation. + * Values MUST be from the list: <js>"http"</js>, <js>"https"</js>, <js>"ws"</js>, <js>"wss"</js>. + * The value overrides the Swagger Object <code>schemes</code> definition. + * + * @param schemes The new values to add to the <property>schemes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addSchemes(Collection<String> schemes) { + if (this.schemes == null) + this.schemes = new LinkedList<String>(); + this.schemes.addAll(schemes); + return this; + } + + /** + * Synonym for {@link #addSchemes(String...)}. + * + * @param schemes The new values to add to the <property>schemes</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation schemes(String...schemes) { + return addSchemes(schemes); + } + + /** + * Bean property getter: <property>deprecated</property>. + * + * <p> + * Declares this operation to be deprecated. + * Usage of the declared operation should be refrained. + * Default value is <jk>false</jk>. + * + * @return The value of the <property>deprecated</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public Boolean getDeprecated() { + return deprecated; + } + + /** + * Bean property setter: <property>deprecated</property>. + * + * <p> + * Declares this operation to be deprecated. + * Usage of the declared operation should be refrained. + * Default value is <jk>false</jk>. + * + * @param deprecated The new value for the <property>deprecated</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setDeprecated(Boolean deprecated) { + this.deprecated = deprecated; + return this; + } + + /** + * Synonym for {@link #setDeprecated(Boolean)}. + * + * @param deprecated The new value for the <property>deprecated</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation deprecated(Boolean deprecated) { + return setDeprecated(deprecated); + } + + /** + * Bean property getter: <property>security</property>. + * + * <p> + * A declaration of which security schemes are applied for this operation. + * The list of values describes alternative security schemes that can be used (that is, there is a logical OR + * between the security requirements). + * This definition overrides any declared top-level security. + * To remove a top-level <code>security</code> declaration, an empty array can be used. + * + * @return The value of the <property>security</property> property on this bean, or <jk>null</jk> if it is not set. + */ + public List<Map<String,List<String>>> getSecurity() { + return security; + } + + /** + * Bean property setter: <property>security</property>. + * + * <p> + * A declaration of which security schemes are applied for this operation. + * The list of values describes alternative security schemes that can be used (that is, there is a logical OR + * between the security requirements). + * This definition overrides any declared top-level security. + * To remove a top-level <code>security</code> declaration, an empty array can be used. + * + * @param security The new value for the <property>security</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation setSecurity(List<Map<String,List<String>>> security) { + this.security = security; + return this; + } + + /** + * Bean property adder: <property>security</property>. + * + * <p> + * A declaration of which security schemes are applied for this operation. + * The list of values describes alternative security schemes that can be used (that is, there is a logical OR + * between the security requirements). + * This definition overrides any declared top-level security. + * To remove a top-level <code>security</code> declaration, an empty array can be used. + * + * @param security The new value to add to the <property>security</property> property on this bean. + * @return This object (for method chaining). + */ + public Operation addSecurity(Map<String,List<String>> security) { + if (this.security == null) + this.security = new LinkedList<Map<String,List<String>>>(); + this.security.add(security); + return this; + } + + /** + * Synonym for {@link #addSecurity(Map)}. + * + * @param scheme The security scheme that applies to this operation + * @param alternatives + * The list of values describes alternative security schemes that can be used (that is, there is a logical OR + * between the security requirements). + * @return This object (for method chaining). + */ + public Operation security(String scheme, String...alternatives) { + Map<String,List<String>> m = new LinkedHashMap<String,List<String>>(); + m.put(scheme, Arrays.asList(alternatives)); + return addSecurity(m); + } +}
