Package io.muserver.openapi
Class ResponsesObjectBuilder
- java.lang.Object
-
- io.muserver.openapi.ResponsesObjectBuilder
-
public class ResponsesObjectBuilder extends java.lang.ObjectA container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance. However, documentation is expected to cover a successful operation response and any known errors.
The
defaultMAY be used as a default response object for all HTTP codes that are not covered individually by the specification.The
Responses ObjectMUST contain at least one response code, and it SHOULD be the response for a successful operation call.
-
-
Constructor Summary
Constructors Constructor Description ResponsesObjectBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponsesObjectbuild()static ResponsesObjectBuildermergeResponses(ResponsesObject primary, ResponsesObject secondary)Creates a new build by merging two exising responsesstatic ResponsesObjectBuilderresponsesObject()Creates a builder for aResponsesObjectResponsesObjectBuilderwithDefaultValue(ResponseObject defaultValue)ResponsesObjectBuilderwithHttpStatusCodes(java.util.Map<java.lang.String,ResponseObject> httpStatusCodes)
-
-
-
Method Detail
-
withDefaultValue
public ResponsesObjectBuilder withDefaultValue(ResponseObject defaultValue)
- Parameters:
defaultValue- The documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses.- Returns:
- The current builder
-
withHttpStatusCodes
public ResponsesObjectBuilder withHttpStatusCodes(java.util.Map<java.lang.String,ResponseObject> httpStatusCodes)
- Parameters:
httpStatusCodes- To define a range of response codes, this field MAY contain the uppercase wildcard characterX. For example,2XXrepresents all response codes between[200-299]. The following range definitions are allowed:1XX,2XX,3XX,4XX, and5XX. If a response range is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.- Returns:
- The current builder
-
build
public ResponsesObject build()
- Returns:
- A new object
-
responsesObject
public static ResponsesObjectBuilder responsesObject()
Creates a builder for aResponsesObject- Returns:
- A new builder
-
mergeResponses
public static ResponsesObjectBuilder mergeResponses(ResponsesObject primary, ResponsesObject secondary)
Creates a new build by merging two exising responses- Parameters:
primary- A responses object to use. This is the dominant response who's values will be preferred when values cannot be merged (such asResponseObject.descriptionsecondary- The other responses object- Returns:
- A builder that is the merged value of the two given ones
-
-