Interface APIResponses
- All Superinterfaces:
Constructible
,Extensible<APIResponses>
This interface represents the container for the expected responses of an operation. The container maps a HTTP response code to the expected
response.
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddAPIResponse
(String name, APIResponse apiResponse) Adds an APIResponse in the format of the name as a key and the item as the value to APIResponses mapdefault APIResponses
defaultValue
(APIResponse defaultValue) Sets the default documentation of responses for this instance of ApiResponses and return this instance of ApiResponses.default APIResponse
getAPIResponse
(String name) Returns a APIResponse for a given name.Returns a copy map (potentially immutable) of the APIResponses.Returns the default documentation of responses other than the ones declared for specific HTTP response codes in this instance of ApiResponses.default boolean
hasAPIResponse
(String name) Check whether a APIResponse is present in the map.void
removeAPIResponse
(String name) Removes the given APIResponse to this APIResponses.void
setAPIResponses
(Map<String, APIResponse> items) Set the APIResponses map to this APIResponsesvoid
setDefaultValue
(APIResponse defaultValue) Sets the default documentation of responses for this instance of ApiResponses.Methods inherited from interface org.eclipse.microprofile.openapi.models.Extensible
addExtension, extensions, getExtensions, removeExtension, setExtensions
-
Field Details
-
DEFAULT
- See Also:
-
-
Method Details
-
addAPIResponse
Adds an APIResponse in the format of the name as a key and the item as the value to APIResponses map- Parameters:
name
- the name of APIResponse (http status code eventually with wildcard or "default")apiResponse
- the APIResponse object to be added to APIResponses map. null values will be rejected (implementation will throw an exception) or ignored.- Returns:
- APIResponses map with the added ApiResponse instance
-
removeAPIResponse
Removes the given APIResponse to this APIResponses.- Parameters:
name
- the name of APIResponse that will be removed (http status code eventually with wildcard or "default")
-
getAPIResponses
Map<String,APIResponse> getAPIResponses()Returns a copy map (potentially immutable) of the APIResponses.- Returns:
- all responses
-
setAPIResponses
Set the APIResponses map to this APIResponses- Parameters:
items
- a map containing all responses. Keys are http statuses code eventually with wildcard or "default".
-
hasAPIResponse
Check whether a APIResponse is present in the map. This is a convenience method forgetAPIResponses().containsKey(name)
- Parameters:
name
- the name of APIResponse (http status code eventually with wildcard or "default")- Returns:
- a boolean to indicate if the APIResponse is present or not.
-
getAPIResponse
Returns a APIResponse for a given name. This is a convenience method forgetAPIResponses().get(name)
- Parameters:
name
- the name of APIResponse (http status code eventually with wildcard or "default")- Returns:
- the corresponding APIResponse or null.
-
getDefaultValue
APIResponse getDefaultValue()Returns the default documentation of responses other than the ones declared for specific HTTP response codes in this instance of ApiResponses.Convenience method that is the same as calling
getAPIResponse(String)
on the map with "default" as value for the key.- Returns:
- the default documentation of responses
-
setDefaultValue
Sets the default documentation of responses for this instance of ApiResponses. This will cover all the undeclared responses.Convenience method that is the same as calling
addAPIResponse(String, APIResponse)
with "default" as value for the key.- Parameters:
defaultValue
- the default documentation of responses
-
defaultValue
Sets the default documentation of responses for this instance of ApiResponses and return this instance of ApiResponses. This will cover all the undeclared responses.Convenience method that is the same as calling
addAPIResponse(String, APIResponse)
with "default" as value for the key.- Parameters:
defaultValue
- the default documentation of responses- Returns:
- this ApiResponses instance
-