Class Swagger
The Swagger Object is the root document that describes an entire API. It contains metadata about the API, available paths and operations, parameters, responses, security definitions, and other information. This is the Swagger 2.0 specification (predecessor to OpenAPI 3.0).
Swagger Specification:
The Swagger Object is composed of the following fields:
- swagger (string, REQUIRED) - The Swagger Specification version (must be- "2.0" )
- info (- Info, REQUIRED) - Provides metadata about the API
- host (string) - The host (name or IP) serving the API
- basePath (string) - The base path on which the API is served (relative to host)
- schemes (array of string) - The transfer protocols of the API (e.g.,- "http" ,- "https" )
- consumes (array of string) - A list of MIME types the APIs can consume
- produces (array of string) - A list of MIME types the APIs can produce
- paths (map of- OperationMap, REQUIRED) - The available paths and operations for the API
- definitions (map of- SchemaInfo) - Schema definitions that can be referenced
- parameters (map of- ParameterInfo) - Parameters definitions that can be referenced
- responses (map of- ResponseInfo) - Response definitions that can be referenced
- securityDefinitions (map of- SecurityScheme) - Security scheme definitions
- security (array of map) - Security requirements applied to all operations
- tags (array of- Tag) - A list of tags used by the specification with additional metadata
- externalDocs (- ExternalDocumentation) - Additional external documentation
Example:
   
See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddConsumes(Collection<MediaType> values) Bean property appender:consumes .addConsumes(MediaType... values) Bean property appender:consumes .addDefinition(String name, JsonMap schema) Bean property appender:definitions .addParameter(String name, ParameterInfo parameter) Bean property appender:parameters .Bean property appender:paths .addProduces(Collection<MediaType> values) Bean property appender:produces .addProduces(MediaType... values) Adds one or more values to theproduces property.addResponse(String name, ResponseInfo response) Bean property appender:responses .addSchemes(String... values) Bean property appender:schemes .addSchemes(Collection<String> values) Bean property appender:schemes .addSecurity(String scheme, String... alternatives) Bean property appender:security .addSecurity(Collection<Map<String, List<String>>> values) Bean property fluent setter:security .addSecurityDefinition(String name, SecurityScheme securityScheme) Bean property appender:securityDefinitions .addTags(Collection<Tag> values) Bean property appender:tags .Bean property appender:tags .asJson()A synonym oftoString().copy()Make a deep copy of this object.<T> TResolves a"$ref" tags to nodes in this swagger document.<T> TGeneric property getter.Bean property getter:basePath .Bean property getter:consumes .Bean property getter:definitions .Bean property getter:externalDocs .getHost()Bean property getter:host .getInfo()Bean property getter:info .getOperation(String path, String operation) Shortcut for callinggetPaths().get(path).get(operation); getParameterInfo(String path, String method, String in, String name) Convenience method for callinggetPath(path).get(method).getParameter(in,name); Bean property getter:parameters .Shortcut for callinggetPaths().get(path); getPaths()Bean property getter:paths .Bean property getter:produces .getResponseInfo(String path, String operation, int status) Shortcut for callinggetPaths().get(path).get(operation).getResponse(status); getResponseInfo(String path, String operation, String status) Shortcut for callinggetPaths().get(path).get(operation).getResponse(status); Bean property getter:responses .Bean property getter:schemes .Bean property getter:security .Bean property getter:securityDefinitions .Bean property getter:swagger .getTags()Bean property getter:tags .keySet()Returns all the keys on this element.Generic property setter.setBasePath(String value) Bean property setter:basePath .setConsumes(Collection<MediaType> value) Bean property setter:consumes .setConsumes(MediaType... value) Bean property fluent setter:consumes .setDefinitions(Map<String, JsonMap> value) Bean property setter:definitions .Bean property setter:externalDocs .Bean property setter:host .Bean property setter:info .setParameters(Map<String, ParameterInfo> value) Bean property setter:parameters .setPaths(Map<String, OperationMap> value) Bean property setter:paths .setProduces(Collection<MediaType> value) Bean property setter:produces .setProduces(MediaType... value) Bean property fluent setter:produces .setResponses(Map<String, ResponseInfo> value) Bean property setter:responses .setSchemes(String... value) Bean property fluent setter:schemes .setSchemes(Collection<String> value) Bean property setter:schemes .setSecurity(Collection<Map<String, List<String>>> value) Bean property setter:security .Bean property setter:securityDefinitions .setSwagger(String value) Bean property setter:swagger .setTags(Collection<Tag> value) Bean property setter:tags .Bean property setter:tags .strict()Sets strict mode on this bean.Sets strict mode on this bean.toString()Methods inherited from class org.apache.juneau.bean.swagger.SwaggerElementasMap, extraKeys, get, isStrict
- 
Field Details- 
NULLRepresents a null swagger
 
- 
- 
Constructor Details- 
Swaggerpublic Swagger()Default constructor.
- 
SwaggerCopy constructor.- Parameters:
- copyFrom- The object to copy.
 
 
- 
- 
Method Details- 
copyMake a deep copy of this object.- Returns:
- A deep copy of this object.
 
- 
getBasePathBean property getter:basePath .The base path on which the API is served, which is relative to the host .- Returns:
- The property value, or null if it is not set.
 
- 
setBasePathBean property setter:basePath .The base path on which the API is served, which is relative to the host .- Parameters:
- 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 path templating.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
getConsumesBean property getter:consumes .A list of MIME types the APIs can consume. - Returns:
- The property value, or null if it is not set.
 
- 
setConsumesBean property setter:consumes .A list of MIME types the APIs can consume. - Parameters:
- value- The new value for this property.
 Value MUST be as described under Swagger Mime Types.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addConsumesBean property appender:consumes .A list of MIME types the APIs can consume. - Parameters:
- values- The values to add to this property.
 Values MUST be as described under Swagger Mime Types.
 Ignored if- null .
- Returns:
- This object.
 
- 
addConsumesBean property appender:consumes .A list of MIME types the APIs can consume. - Parameters:
- values- The values to add to this property.
 Ignored if- null .
- Returns:
- This object.
 
- 
setConsumesBean property fluent setter:consumes .A list of MIME types the APIs can consume. - Parameters:
- value- The values to set on this property.
- Returns:
- This object.
 
- 
getDefinitionsBean property getter:definitions .An object to hold data types produced and consumed by operations. - Returns:
- The property value, or null if it is not set.
 
- 
setDefinitionsBean property setter:definitions .An object to hold data types produced and consumed by operations. - Parameters:
- value- The new value for this property.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addDefinitionBean property appender:definitions .Adds a single value to the definitions property.- Parameters:
- name- A definition name. Must not be- null .
- schema- The schema that the name defines. Must not be- null .
- Returns:
- This object.
 
- 
getExternalDocsBean property getter:externalDocs .Additional external documentation. - Returns:
- The property value, or null if it is not set.
 
- 
setExternalDocsBean property setter:externalDocs .Additional external documentation. - Parameters:
- value- The new value for this property.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
getHostBean property getter:host .The host (name or IP) serving the API. - Returns:
- The property value, or null if it is not set.
 
- 
setHostBean property setter:host .The host (name or IP) serving the API. - Parameters:
- 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 path templating
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
getInfoBean property getter:info .Provides metadata about the API. - Returns:
- The property value, or null if it is not set.
 
- 
setInfoBean property setter:info .Provides metadata about the API. - Parameters:
- value- The new value for this property.
 Property value is required.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
getParametersBean property getter:parameters .An object to hold parameters that can be used across operations. - Returns:
- The property value, or null if it is not set.
 
- 
setParametersBean property setter:parameters .An object to hold parameters that can be used across operations. - Parameters:
- value- The new value for this property.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addParameterBean property appender:parameters .Adds a single value to the parameter property.- Parameters:
- name- The parameter name. Must not be- null .
- parameter- The parameter definition. Must not be- null .
- Returns:
- This object.
 
- 
getPathsBean property getter:paths .The available paths and operations for the API. - Returns:
- The property value, or null if it is not set.
 
- 
setPathsBean property setter:paths .The available paths and operations for the API. - Parameters:
- value- The new value for this property.
 Property value is required.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addPathBean property appender:paths .Adds a single value to the paths property.- Parameters:
- path- The path template. Must not be- null .
- methodName- The HTTP method name. Must not be- null .
- operation- The operation that describes the path. Must not be- null .
- Returns:
- This object.
 
- 
getProducesBean property getter:produces .A list of MIME types the APIs can produce. - Returns:
- The property value, or null if it is not set.
 
- 
setProducesBean property setter:produces .A list of MIME types the APIs can produce. - Parameters:
- value- The new value for this property.
 Value MUST be as described under Swagger Mime Types.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addProducesAdds one or more values to theproduces property.A list of MIME types the APIs can produce. - Parameters:
- values- The values to add to this property.
 Value MUST be as described under Swagger Mime Types.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addProducesBean property appender:produces .A list of MIME types the APIs can produce. - Parameters:
- values- The values to add to this property.
 Value MUST be as described under Swagger Mime Types.
 Ignored if- null .
- Returns:
- This object.
 
- 
setProducesBean property fluent setter:produces .A list of MIME types the APIs can produce. - Parameters:
- value- The new value for this property.
- Returns:
- This object.
 
- 
getResponsesBean property getter:responses .An object to hold responses that can be used across operations. - Returns:
- The property value, or null if it is not set.
 
- 
setResponsesBean property setter:responses .An object to hold responses that can be used across operations. - Parameters:
- value- The new value for this property.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addResponseBean property appender:responses .Adds a single value to the responses property.- Parameters:
- name- The response name. Must not be- null .
- response- The response definition. Must not be- null .
- Returns:
- This object.
 
- 
getSchemesBean property getter:schemes .The transfer protocol of the API. - Returns:
- The property value, or null if it is not set.
 
- 
setSchemesBean property setter:schemes .The transfer protocol of the API. - Parameters:
- value- The new value for this property.
 Valid values:- "http" 
- "https" 
- "ws" 
- "wss" 
 
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addSchemesBean property appender:schemes .The transfer protocol of the API. - Parameters:
- values- The values to add to this property.
 Valid values:- "http" 
- "https" 
- "ws" 
- "wss" 
 
 Ignored if- null .
- Returns:
- This object.
 
- 
addSchemesBean property appender:schemes .The transfer protocol of the API. - Parameters:
- values- The values to add to this property.
 Valid values:- "http" 
- "https" 
- "ws" 
- "wss" 
 
 Ignored if- null .
- Returns:
- This object.
 
- 
setSchemesBean property fluent setter:schemes .The transfer protocol of the API. - Parameters:
- value- The new value for this property.
 Strings can be JSON arrays.
- Returns:
- This object.
 
- 
getSecurityBean property getter:security .A declaration of which security schemes are applied for the API as a whole. - Returns:
- The property value, or null if it is not set.
 
- 
setSecurityBean property setter:security .A declaration of which security schemes are applied for the API as a whole. - Parameters:
- value- The new value for this property.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addSecurityBean property appender:security .Adds a single value to the securityDefinitions property.- Parameters:
- scheme- The security scheme that applies to this operation Must not be- null .
- alternatives- The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements).
- Returns:
- This object.
 
- 
addSecurityBean property fluent setter:security .A declaration of which security schemes are applied for the API as a whole. - Parameters:
- values- The values to add to this property.
 Ignored if- null .
- Returns:
- This object.
 
- 
getSecurityDefinitionsBean property getter:securityDefinitions .Security scheme definitions that can be used across the specification. - Returns:
- The property value, or null if it is not set.
 
- 
setSecurityDefinitionsBean property setter:securityDefinitions .Security scheme definitions that can be used across the specification. - Parameters:
- value- The new value for this property.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
addSecurityDefinitionBean property appender:securityDefinitions .Adds a single value to the securityDefinitions property.- Parameters:
- name- A security name. Must not be- null .
- securityScheme- A security schema. Must not be- null .
- Returns:
- This object.
 
- 
getSwaggerBean property getter:swagger .Specifies the Swagger Specification version being used. - Returns:
- The property value, or null if it is not set.
 
- 
setSwaggerBean property setter:swagger .Specifies the Swagger Specification version being used. - Parameters:
- value- The new value for this property.
 Property value is required.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
getTagsBean property getter:tags .A list of tags used by the specification with additional metadata. - Returns:
- The property value, or null if it is not set.
 
- 
setTagsBean property setter:tags .A list of tags used by the specification with additional metadata. - Parameters:
- value- The new value for this property.
 The order of the tags can be used to reflect on their order by the parsing tools.
 Not all tags that are used by the Operation Object must be declared.
 The tags that are not declared may be organized randomly or based on the tools' logic.
 Each tag name in the list MUST be unique.
 Can be- null to unset the property.
- Returns:
- This object.
 
- 
setTagsBean property setter:tags .A list of tags used by the specification with additional metadata. - Parameters:
- value- The new value for this property.
 The order of the tags can be used to reflect on their order by the parsing tools.
 Not all tags that are used by the Operation Object must be declared.
 The tags that are not declared may be organized randomly or based on the tools' logic.
 Each tag name in the list MUST be unique.
 Ignored if- null .
- Returns:
- This object.
 
- 
addTagsBean property appender:tags .A list of tags used by the specification with additional metadata. - Parameters:
- values- The values to add to this property.
 The order of the tags can be used to reflect on their order by the parsing tools.
 Not all tags that are used by the Operation Object must be declared.
 The tags that are not declared may be organized randomly or based on the tools' logic.
 Each tag name in the list MUST be unique.
 Ignored if- null .
- Returns:
- This object.
 
- 
addTagsBean property appender:tags .A list of tags used by the specification with additional metadata. - Parameters:
- values- The values to add to this property.
 The order of the tags can be used to reflect on their order by the parsing tools.
 Not all tags that are used by the Operation Object must be declared.
 The tags that are not declared may be organized randomly or based on the tools' logic.
 Each tag name in the list MUST be unique.
 Ignored if- null .
- Returns:
- This object.
 
- 
getPathShortcut for callinggetPaths().get(path); - Parameters:
- path- The path (e.g.- "/foo" ). Must not be- null .
- Returns:
- The operation map for the specified path, or null if it doesn't exist.
 
- 
getOperationShortcut for callinggetPaths().get(path).get(operation); - Parameters:
- path- The path (e.g.- "/foo" ). Must not be- null .
- operation- The HTTP operation (e.g.- "get" ). Must not be- null .
- Returns:
- The operation for the specified path and operation id, or null if it doesn't exist.
 
- 
getResponseInfoShortcut for callinggetPaths().get(path).get(operation).getResponse(status); - Parameters:
- path- The path (e.g.- "/foo" ). Must not be- null .
- operation- The HTTP operation (e.g.- "get" ). Must not be- null .
- status- The HTTP response status (e.g.- "200" ). Must not be- null .
- Returns:
- The operation for the specified path and operation id, or null if it doesn't exist.
 
- 
getResponseInfoShortcut for callinggetPaths().get(path).get(operation).getResponse(status); - Parameters:
- path- The path (e.g.- "/foo" ).
- operation- The HTTP operation (e.g.- "get" ).
- status- The HTTP response status (e.g.- "200" ).
- Returns:
- The operation for the specified path and operation id, or null if it doesn't exist.
 
- 
getParameterInfoConvenience method for callinggetPath(path).get(method).getParameter(in,name); - Parameters:
- path- The HTTP path. Must not be- null .
- method- The HTTP method. Must not be- null .
- in- The parameter type. Must not be- null .
- name- The parameter name. Can be- null for parameter type- body .
- Returns:
- The parameter information or null if not found.
 
- 
getDescription copied from class:SwaggerElementGeneric property getter.Can be used to retrieve non-standard Swagger fields such as "$ref" .- Overrides:
- getin class- SwaggerElement
- Type Parameters:
- T- The datatype to cast the value to.
- Parameters:
- property- The property name to retrieve.
- type- The datatype to cast the value to.
- Returns:
- The property value, or null if the property does not exist or is not set.
 
- 
setDescription copied from class:SwaggerElementGeneric property setter.Can be used to set non-standard Swagger fields such as "$ref" .- Overrides:
- setin class- SwaggerElement
- Parameters:
- property- The property name to set. Must not be- null .
- value- The new value for the property.
- Returns:
- This object.
 
- 
keySetDescription copied from class:SwaggerElementReturns all the keys on this element.- Overrides:
- keySetin class- SwaggerElement
- Returns:
- All the keys on this element.
   
 Nevernull .
 
- 
asJsonA synonym oftoString().- Returns:
- This object serialized as JSON.
 
- 
toString- Overrides:
- toStringin class- SwaggerElement
 
- 
findRefResolves a"$ref" tags to nodes in this swagger document.- Type Parameters:
- T- The class to convert the reference to.
- Parameters:
- ref- The ref tag value. Must not be- null or blank.
- c- The class to convert the reference to. Must not be- null .
- Returns:
- The referenced node, or null if not found.
 
- 
strictSets strict mode on this bean.- Overrides:
- strictin class- SwaggerElement
- Returns:
- This object.
 
- 
strictSets strict mode on this bean.- Overrides:
- strictin class- SwaggerElement
- Parameters:
- value- The new value for this property.
 Non-boolean values will be converted to boolean using- Boolean..- valueOf (value.toString())
 Can be- null (interpreted as- false ).
- Returns:
- This object.
 
 
-