e2 : e.getValue().entrySet())
m.put(e2.getKey(), e2.getValue().copy());
this.paths.put(e.getKey(), m);
}
}
/**
* Make a deep copy of this object.
*
* @return A deep copy of this object.
*/
public Swagger copy() {
return new Swagger(this);
}
/**
* Bean property getter: swagger.
*
*
* Specifies the Swagger Specification version being used.
*
*
* It can be used by the Swagger UI and other clients to interpret the API listing.
*
* @return The property value, or null if it is not set.
*/
public String getSwagger() {
return swagger;
}
/**
* Bean property setter: swagger.
*
*
* Specifies the Swagger Specification version being used.
*
*
* It can be used by the Swagger UI and other clients to interpret the API listing.
*
* @param value
* The new value for this property.
*
Property value is required.
* @return This object (for method chaining).
*/
public Swagger setSwagger(String value) {
swagger = value;
return this;
}
/**
* Same as {@link #setSwagger(String)}.
*
* @param value
* The new value for this property.
*
Non-String values will be converted to String using toString()
.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger swagger(Object value) {
return setSwagger(toStringVal(value));
}
/**
* Bean property getter: info.
*
*
* Provides metadata about the API.
*
*
* The metadata can be used by the clients if needed.
*
* @return The property value, or null if it is not set.
*/
public Info getInfo() {
return info;
}
/**
* Bean property setter: info.
*
*
* Provides metadata about the API.
*
*
* The metadata can be used by the clients if needed.
*
* @param value
* The new value for this property.
*
Property value is required.
* @return This object (for method chaining).
*/
public Swagger setInfo(Info value) {
info = value;
return this;
}
/**
* Same as {@link #setInfo(Info)}.
*
* @param value
* The new value for this property.
*
Valid types:
*
*
Property value is required.
* @return This object (for method chaining).
*/
public Swagger info(Object value) {
return setInfo(toType(value, Info.class));
}
/**
* Bean property getter: host.
*
*
* The host (name or IP) serving the API.
*
* @return The property value, or null if it is not set.
*/
public String getHost() {
return host;
}
/**
* Bean property setter: host.
*
*
* The host (name or IP) serving the API.
*
* @param value
* The new value for this property.
*
This MUST be the host only and does not include the scheme nor sub-paths.
*
It MAY include a port.
*
If the host is not included, the host serving the documentation is to be used (including the port).
*
The host does not support {@doc SwaggerPathTemplating path templating}
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setHost(String value) {
host = value;
return this;
}
/**
* Same as {@link #setHost(String)}.
*
* @param value
* The new value for this property.
*
Non-String values will be converted to String using toString()
.
*
This MUST be the host only and does not include the scheme nor sub-paths.
*
It MAY include a port.
*
If the host is not included, the host serving the documentation is to be used (including the port).
*
The host does not support {@doc SwaggerPathTemplating path templating}
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger host(Object value) {
return setHost(toStringVal(value));
}
/**
* Bean property getter: basePath.
*
*
* The base path on which the API is served, which is relative to the host
.
*
* @return The property value, or null if it is not set.
*/
public String getBasePath() {
return basePath;
}
/**
* Bean property setter: basePath.
*
*
* The base path on which the API is served, which is relative to the host
.
*
* @param value
* The new value for this property.
*
If it is not included, the API is served directly under the host
.
*
The value MUST start with a leading slash (/).
*
The basePath
does not support {@doc SwaggerPathTemplating path templating}.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setBasePath(String value) {
basePath = value;
return this;
}
/**
* Same as {@link #setBasePath(String)}.
*
* @param value
* The new value for this property.
*
Non-String values will be converted to String using toString()
.
*
If it is not included, the API is served directly under the host
.
*
The value MUST start with a leading slash (/).
*
The basePath
does not support {@doc SwaggerPathTemplating path templating}.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger basePath(Object value) {
return setBasePath(toStringVal(value));
}
/**
* Bean property getter: schemes.
*
*
* The transfer protocol of the API.
*
*
* If the schemes
is not included, the default scheme to be used is the one used to access the Swagger
* definition itself.
*
* @return The property value, or null if it is not set.
*/
public List getSchemes() {
return schemes;
}
/**
* Bean property setter: schemes.
*
*
* The transfer protocol of the API.
*
*
* If the schemes
is not included, the default scheme to be used is the one used to access the Swagger
* definition itself.
*
* @param value
* The new value for this property.
*
Valid values:
*
* - "http"
*
- "https"
*
- "ws"
*
- "wss"
*
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setSchemes(Collection value) {
schemes = newList(value);
return this;
}
/**
* Adds one or more values to the schemes property.
*
*
* The transfer protocol of the API.
*
*
* Values MUST be from the list: "http", "https", "ws", "wss".
* If the schemes
is not included, the default scheme to be used is the one used to access the Swagger
* definition itself.
*
* @param values
* The values to add to this property.
*
Valid values:
*
* - "http"
*
- "https"
*
- "ws"
*
- "wss"
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addSchemes(Collection values) {
schemes = addToList(schemes, values);
return this;
}
/**
* Same as {@link #addSchemes(Collection)}.
*
* @param values
* The values to add to this property.
*
Valid types:
*
* Collection<String>
* String
- JSON array representation of Collection<String>
*
*
* schemes("['scheme1','scheme2']");
*
* String
- Individual values
*
*
* schemes("scheme1", "scheme2");
*
*
* @return This object (for method chaining).
*/
public Swagger schemes(Object...values) {
schemes = addToList(schemes, values, String.class);
return this;
}
/**
* Bean property getter: consumes.
*
*
* A list of MIME types the APIs can consume.
*
*
* This is global to all APIs but can be overridden on specific API calls.
*
* @return The property value, or null if it is not set.
*/
public List getConsumes() {
return consumes;
}
/**
* Bean property setter: consumes.
*
*
* A list of MIME types the APIs can consume.
*
*
* This is global to all APIs but can be overridden on specific API calls.
*
* @param value
* The new value for this property.
*
Value MUST be as described under {@doc SwaggerMimeTypes}.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setConsumes(Collection value) {
consumes = newList(value);
return this;
}
/**
* Adds one or more values to the consumes property.
*
*
* A list of MIME types the operation can consume.
* This overrides the consumes
definition at the Swagger Object.
* An empty value MAY be used to clear the global definition.
* Value MUST be as described under {@doc SwaggerMimeTypes}.
*
* @param values
* The values to add to this property.
*
Values MUST be as described under {@doc SwaggerMimeTypes}.
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addConsumes(Collection values) {
consumes = addToList(consumes, values);
return this;
}
/**
* Adds one or more values to the consumes property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger consumes(Object...values) {
consumes = addToList(consumes, values, MediaType.class);
return this;
}
/**
* Bean property getter: produces.
*
*
* A list of MIME types the APIs can produce.
*
*
* This is global to all APIs but can be overridden on specific API calls.
*
* @return The property value, or null if it is not set.
*/
public List getProduces() {
return produces;
}
/**
* Bean property setter: produces.
*
*
* A list of MIME types the APIs can produce.
*
*
* This is global to all APIs but can be overridden on specific API calls.
*
* @param value
* The new value for this property.
*
Value MUST be as described under {@doc SwaggerMimeTypes}.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setProduces(Collection value) {
produces = newList(value);
return this;
}
/**
* Adds one or more values to the produces property.
*
*
* A list of MIME types the APIs can produce.
*
*
* This is global to all APIs but can be overridden on specific API calls.
*
* @param values
* The values to add to this property.
*
Value MUST be as described under {@doc SwaggerMimeTypes}.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger addProduces(Collection values) {
produces = addToList(produces, values);
return this;
}
/**
* Adds one or more values to the produces property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger produces(Object...values) {
produces = addToList(produces, values, MediaType.class);
return this;
}
/**
* Bean property getter: paths.
*
*
* The available paths and operations for the API.
*
* @return The property value, or null if it is not set.
*/
public Map getPaths() {
return paths;
}
/**
* Shortcut for calling getPaths().get(path);
*
* @param path The path (e.g. "/foo").
* @return The operation map for the specified path, or null if it doesn't exist.
*/
public OperationMap getPath(String path) {
return getPaths().get(path);
}
/**
* Shortcut for calling getPaths().get(path).get(operation);
*
* @param path The path (e.g. "/foo").
* @param operation The HTTP operation (e.g. "get").
* @return The operation for the specified path and operation id, or null if it doesn't exist.
*/
public Operation getOperation(String path, String operation) {
OperationMap om = getPath(path);
if (om == null)
return null;
return om.get(operation);
}
/**
* Shortcut for calling getPaths().get(path).get(operation).getResponse(status);
*
* @param path The path (e.g. "/foo").
* @param operation The HTTP operation (e.g. "get").
* @param status The HTTP response status (e.g. "200").
* @return The operation for the specified path and operation id, or null if it doesn't exist.
*/
public ResponseInfo getResponseInfo(String path, String operation, Object status) {
OperationMap om = getPath(path);
if (om == null)
return null;
Operation op = om.get(operation);
if (op == null)
return null;
return op.getResponse(status);
}
/**
* Bean property setter: paths.
*
*
* The available paths and operations for the API.
*
* @param value
* The new value for this property.
*
Property value is required.
* @return This object (for method chaining).
*/
public Swagger setPaths(Map value) {
paths = newSortedMap(value, PATH_COMPARATOR);
return this;
}
/**
* Adds one or more values to the produces property.
*
*
* A list of MIME types the APIs can produce.
*
*
* This is global to all APIs but can be overridden on specific API calls.
*
* @param values
* The values to add to this property.
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addPaths(Map values) {
paths = addToSortedMap(paths, values, PATH_COMPARATOR);
return this;
}
/**
* Adds a single value to the paths property.
*
* @param path The path template.
* @param methodName The HTTP method name.
* @param operation The operation that describes the path.
* @return This object (for method chaining).
*/
public Swagger path(String path, String methodName, Operation operation) {
if (paths == null)
paths = new TreeMap<>(PATH_COMPARATOR);
OperationMap p = paths.get(path);
if (p == null) {
p = new OperationMap();
paths.put(path, p);
}
p.put(methodName, operation);
return this;
}
/**
* Adds one or more values to the paths property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public Swagger paths(Object...values) {
if (paths == null)
paths = new TreeMap<>(PATH_COMPARATOR);
paths = addToMap((Map)paths, values, String.class, Map.class, String.class, Operation.class);
return this;
}
/**
* Bean property getter: definitions.
*
*
* An object to hold data types produced and consumed by operations.
*
* @return The property value, or null if it is not set.
*/
public Map getDefinitions() {
return definitions;
}
/**
* Bean property setter: definitions.
*
*
* An object to hold data types produced and consumed by operations.
*
* @param value
* The new value for this property.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setDefinitions(Map value) {
definitions = newMap(value);
return this;
}
/**
* Adds one or more values to the definitions property.
*
*
* An object to hold data types produced and consumed by operations.
*
* @param values
* The values to add to this property.
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addDefinitions(Map values) {
definitions = addToMap(definitions, values);
return this;
}
/**
* Adds a single value to the definitions property.
*
* @param name A definition name.
* @param schema The schema that the name defines.
* @return This object (for method chaining).
*/
public Swagger definition(String name, ObjectMap schema) {
definitions = addToMap(definitions, name, schema);
return this;
}
/**
* Adds one or more values to the definitions property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger definitions(Object...values) {
definitions = addToMap(definitions, values, String.class, ObjectMap.class);
return this;
}
/**
* Convenience method for testing whether this Swagger has one or more definitions defined.
*
* @return true if this Swagger has one or more definitions defined.
*/
public boolean hasDefinitions() {
return definitions != null && ! definitions.isEmpty();
}
/**
* Bean property getter: parameters.
*
*
* An object to hold parameters that can be used across operations.
*
*
* This property does not define global parameters for all operations.
*
* @return The property value, or null if it is not set.
*/
public Map getParameters() {
return parameters;
}
/**
* Bean property setter: parameters.
*
*
* An object to hold parameters that can be used across operations.
*
*
* This property does not define global parameters for all operations.
*
* @param value
* The new value for this property.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setParameters(Map value) {
parameters = newMap(value);
return this;
}
/**
* Adds one or more values to the parameters property.
*
*
* An object to hold parameters that can be used across operations.
*
*
* This property does not define global parameters for all operations.
*
* @param values
* The values to add to this property.
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addParameters(Map values) {
parameters = addToMap(parameters, values);
return this;
}
/**
* Adds a single value to the parameter property.
*
* @param name The parameter name.
* @param parameter The parameter definition.
* @return This object (for method chaining).
*/
public Swagger parameter(String name, ParameterInfo parameter) {
parameters = addToMap(parameters, name, parameter);
return this;
}
/**
* Adds one or more values to the properties property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger parameters(Object...values) {
parameters = addToMap(parameters, values, String.class, ParameterInfo.class);
return this;
}
/**
* Convenience method for calling getPath(path).get(method).getParameter(in,name);
*
* @param path The HTTP path.
* @param method The HTTP method.
* @param in The parameter type.
* @param name The parameter name.
* @return The parameter information or null if not found.
*/
public ParameterInfo getParameterInfo(String path, String method, String in, String name) {
OperationMap om = getPath(path);
if (om != null) {
Operation o = om.get(method);
if (o != null) {
return o.getParameter(in, name);
}
}
return null;
}
/**
* Bean property getter: responses.
*
*
* An object to hold responses that can be used across operations.
*
*
* This property does not define global responses for all operations.
*
* @return The property value, or null if it is not set.
*/
public Map getResponses() {
return responses;
}
/**
* Bean property setter: responses.
*
*
* An object to hold responses that can be used across operations.
*
*
* This property does not define global responses for all operations.
*
* @param value
* The new value for this property.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setResponses(Map value) {
responses = newMap(value);
return this;
}
/**
* Adds one or more values to the responses property.
*
*
* An object to hold responses that can be used across operations.
*
*
* This property does not define global responses for all operations.
*
* @param values
* The values to add to this property.
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addResponses(Map values) {
responses = addToMap(responses, values);
return this;
}
/**
* Adds a single value to the responses property.
*
* @param name The response name.
* @param response The response definition.
* @return This object (for method chaining).
*/
public Swagger response(String name, ResponseInfo response) {
responses = addToMap(responses, name, response);
return this;
}
/**
* Adds one or more values to the properties property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger responses(Object...values) {
responses = addToMap(responses, values, String.class, ResponseInfo.class);
return this;
}
/**
* Bean property getter: securityDefinitions.
*
*
* Security scheme definitions that can be used across the specification.
*
* @return The property value, or null if it is not set.
*/
public Map getSecurityDefinitions() {
return securityDefinitions;
}
/**
* Bean property setter: securityDefinitions.
*
*
* Security scheme definitions that can be used across the specification.
*
* @param value
* The new value for this property.
*
Can be null to unset the property.
* @return This object (for method chaining).
*/
public Swagger setSecurityDefinitions(Map value) {
securityDefinitions = newMap(value);
return this;
}
/**
* Adds one or more values to the securityDefinitions property.
*
*
* Security scheme definitions that can be used across the specification.
*
* @param values
* The values to add to this property.
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger addSecurityDefinitions(Map values) {
securityDefinitions = addToMap(securityDefinitions, values);
return this;
}
/**
* Adds a single value to the securityDefinitions property.
*
* @param name A security name.
* @param securityScheme A security schema.
* @return This object (for method chaining).
*/
public Swagger securityDefinition(String name, SecurityScheme securityScheme) {
securityDefinitions = addToMap(securityDefinitions, name, securityScheme);
return this;
}
/**
* Adds one or more values to the securityDefinitions property.
*
* @param values
* The values to add to this property.
*
Valid types:
*
*
Ignored if null.
* @return This object (for method chaining).
*/
public Swagger securityDefinitions(Object...values) {
securityDefinitions = addToMap(securityDefinitions, values, String.class, SecurityScheme.class);
return this;
}
/**
* Bean property getter: security.
*
*
* A declaration of which security schemes are applied for the API as a whole.
*
*
* The list of values describes alternative security schemes that can be used (that is, there is a logical OR
* between the security requirements).
*
Individual operations can override this definition.
*
* @return The property value, or null if it is not set.
*/
public List