Class OpenApi
The OpenAPI Object is the root document that describes an entire API. It contains metadata about the API, available paths and operations, parameters, responses, authentication methods, and other information.
OpenAPI Specification:
The OpenAPI Object is composed of the following fields:
openapi (string, REQUIRED) - The OpenAPI Specification version (e.g., "3.0.0")info (Info
, REQUIRED) - Provides metadata about the APIservers (array ofServer
) - An array of Server Objects providing connectivity informationpaths (map ofPathItem
) - The available paths and operations for the APIcomponents (Components
) - An element to hold various schemas for reusesecurity (array ofSecurityRequirement
) - Security mechanisms applied to all operationstags (array ofTag
) - A list of tags for API documentation controlexternalDocs (ExternalDocumentation
) - Additional external documentation
Example:
See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a path to this OpenAPI document.addSecurity
(Collection<SecurityRequirement> values) Bean property fluent setter:security .addSecurity
(SecurityRequirement... values) Bean property fluent setter:security .addServers
(Collection<Server> values) Bean property fluent setter:servers .addServers
(Server... values) Bean property fluent setter:servers .addTags
(Collection<Tag> values) Bean property appender:tags .Bean property appender:tags .copy()
Make a deep copy of this object.<T> T
Finds a reference within this OpenAPI document.<T> T
Generic property getter.Returns the components object.Returns the external documentation.getInfo()
Returns the info object.Returns the OpenAPI version.getPaths()
Returns the paths map.Returns the security requirements list.Returns the servers list.getTags()
Returns the tags list.keySet()
Returns all the keys on this element.Generic property setter.setComponents
(Components value) Sets the components object.Sets the external documentation.Sets the info object.setOpenapi
(String value) Sets the OpenAPI version.Sets the paths map.setSecurity
(List<SecurityRequirement> value) Sets the security requirements list.setServers
(List<Server> value) Sets the servers list.Sets the tags list.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.openapi3.OpenApiElement
asMap, extraKeys, get, isStrict
-
Field Details
-
NULL
Represents a null OpenAPI document
-
-
Constructor Details
-
OpenApi
public OpenApi()Default constructor. -
OpenApi
Copy constructor.- Parameters:
copyFrom
- The object to copy.
-
-
Method Details
-
copy
Make a deep copy of this object.- Returns:
- A deep copy of this object.
-
getOpenapi
Returns the OpenAPI version.- Returns:
- The OpenAPI version.
-
setOpenapi
Sets the OpenAPI version.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
getInfo
Returns the info object.- Returns:
- The info object.
-
setInfo
Sets the info object.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
getServers
Returns the servers list.- Returns:
- The servers list.
-
setServers
Sets the servers list.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
getPaths
Returns the paths map.- Returns:
- The paths map.
-
setPaths
Sets the paths map.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
addPath
Adds a path to this OpenAPI document.- Parameters:
path
- The path string. Must not benull .pathItem
- The path item. Must not benull .- Returns:
- This object.
-
getComponents
Returns the components object.- Returns:
- The components object.
-
setComponents
Sets the components object.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
getSecurity
Returns the security requirements list.- Returns:
- The security requirements list.
-
setSecurity
Sets the security requirements list.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
getTags
Returns the tags list.- Returns:
- The tags list.
-
setTags
Sets the tags list.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
setTags
Bean property setter:tags .A list of tags used by the specification with additional metadata.
- Parameters:
value
- The new value for this property.
Ignored ifnull .- Returns:
- This object.
-
addTags
Bean property appender:tags .A list of tags used by the specification with additional metadata.
- Parameters:
values
- The values to add to this property.
Ignored ifnull .- Returns:
- This object.
-
addTags
Bean property appender:tags .A list of tags used by the specification with additional metadata.
- Parameters:
values
- The values to add to this property.
Ignored ifnull .- Returns:
- This object.
-
addServers
Bean property fluent setter:servers .An array of Server Objects, which provide connectivity information to a target server.
- Parameters:
values
- The values to add to this property.
Ignored ifnull .- Returns:
- This object.
-
addServers
Bean property fluent setter:servers .An array of Server Objects, which provide connectivity information to a target server.
- Parameters:
values
- The values to add to this property.
Ignored ifnull .- Returns:
- This object.
-
addSecurity
Bean property fluent setter:security .A declaration of which security mechanisms can be used across the API.
- Parameters:
values
- The values to add to this property.
Ignored ifnull .- Returns:
- This object.
-
addSecurity
Bean property fluent setter:security .A declaration of which security mechanisms can be used across the API.
- Parameters:
values
- The values to add to this property.
Ignored ifnull .- Returns:
- This object.
-
getExternalDocs
Returns the external documentation.- Returns:
- The external documentation.
-
setExternalDocs
Sets the external documentation.- Parameters:
value
- The new value for this property.- Returns:
- This object.
-
findRef
Finds a reference within this OpenAPI document.- Parameters:
ref
- The reference string (e.g.,"#/components/schemas/User" ). Must not benull or blank.c
- The expected class type. Must not benull .- Returns:
- The referenced node, or
null if not found.
-
toString
- Overrides:
toString
in classOpenApiElement
-
get
Description copied from class:OpenApiElement
Generic property getter.Can be used to retrieve non-standard Swagger fields such as
"$ref" .- Overrides:
get
in classOpenApiElement
- 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.
-
set
Description copied from class:OpenApiElement
Generic property setter.Can be used to set non-standard Swagger fields such as
"$ref" .- Overrides:
set
in classOpenApiElement
- Parameters:
property
- The property name to set. Must not benull .value
- The new value for the property.- Returns:
- This object
-
keySet
Description copied from class:OpenApiElement
Returns all the keys on this element.- Overrides:
keySet
in classOpenApiElement
- Returns:
- All the keys on this element.
Nevernull .
-
strict
Description copied from class:OpenApiElement
Sets strict mode on this bean.- Overrides:
strict
in classOpenApiElement
- Returns:
- This object
-
strict
Description copied from class:OpenApiElement
Sets strict mode on this bean.- Overrides:
strict
in classOpenApiElement
- Parameters:
value
- The new value for this property.
Non-boolean values will be converted to boolean usingBoolean.
.valueOf (value.toString())
Can benull (interpreted asfalse ).- Returns:
- This object
-